Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subroutine mrqmin, parameter constraints

Status
Not open for further replies.

ara82

Technical User
Dec 7, 2011
4
GB

I'm using the mrqmin subroutine to perform a non linear fitting, but I would need to restrict the values that the parameters can reach by lower and upper bounds. I don't find the way to do it. If anyone could help me, I would be very grateful. Thanks in advance
 
mikrom, thank you very much for your quick reply. I had already looked for it in Numerical Recipes, but I think that this code allows to fit the parameters to any value or to hold fixed at their input values, but not to limit the possible values they can reach. Am I wrong?

P.S. Apologize for the mistakes that I make when I write in English, it is not my native language. Hope you understand me.


 
What values do you wish to restrict? Is it the values that funcs returns?

What do you want to happen when the y value is out of range?

o should it be set to the min or max value, depending on which way it is out of range
o should the x value be taken out
o should it stop processing at that point
o should it do something completely different

 
As xwb said, you should specify what you want to restrict.

I thing you could use the subroutine as is and restrict the values outside of it. I mean something like following schema:
Code:
! restrict input parameters before the procedure call
....

call mrqmin (x, y, ...)

! restrict result values after the procedure call
....
 
The model I want to fit to the data has 8 parameters (it is a complex model). The code works well and I obtain the best fitting, but the problem is that in this fitting the values that 2 of the parameters reach have no sense for my purposes (for example, one of them reachs a negative value). I want to obtain the best possible fitting if these parameters are bounded between two fixed values.
 
I want to obtain the best possible fitting if these parameters are bounded between two fixed values.
It would sounds like a optimization problem, but as I understood these 2 parameters are not input parameters, but output parameters of the procedure.
 
They are input and output parameters, array a(1:ma) in the subroutine
mrqmin(x,y,sig,ndata,a,ia,ma,covar,alpha,nca,chisq,funcs,alamda)

On the first call I provide an initial guess for a(1:ma) and the program returns the best values for a(1:ma) that minimize the value χ^2 of the fit between a set of data points x(1:ndata), y(1:ndata) and my nonlinear model dependent on ma coefficients.

By the array ia(1:ma) I can decide if I want to hold fixed some of the ma parameters, but the question was how could I bound them with upper and lower limits?
 
I must say, I have no idea how to do it.
IMO, you will need to write your own modification of the procedure, if possible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top