LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fit functions with optionally fixed parameters?

How can I fit functions ranging from a basic linear fit to any user-defined function to a set of x-y data with the option of keeping single fit parameters fixed (e.g. a known slope in a linear fit)? One possibility would be creating an according formula for the Levenberg-Marquard-algorithm each time a parameter is set to be fixed but that seems to be a bit inconvenient. Is there a simple approach to this problem, I guess I'm not the first to try it? Thanks a lot,
Daniel
0 Kudos
Message 1 of 5
(3,850 Views)

Hi,

have a look on this forum entry: http://forums.ni.com/ni/board/message?board.id=170&message.id=30453

regards,ThSa

0 Kudos
Message 2 of 5
(3,822 Views)


@dtroendle wrote:
How can I fit functions ranging from a basic linear fit to any user-defined function to a set of x-y data with the option of keeping single fit parameters fixed (e.g. a known slope in a linear fit)? Is there a simple approach to this problem, I guess I'm not the first to try it?

Daniel,

I have modified the Lev-Mar routines long ago to allow the runtime selection of which paramters should be fixed and which should be held constant. It is not very difficult to implement. I use it to fit EPR spectra where the model can have up to ~30 parameters, but typically only less than 10 are fit while the rest are kept constant.

Basically, I added a boolean array as input to Lev-Mar which has the same number of elements as the number of paramters of the model function. For each element, a TRUE means that the corresponding parameter should be fit while a FALSE means that the corresponding parameter should be held fixed at the value of the initial estimate.

You just need to seperate out the reduced problem for the fitting part, but carry all parameters along for the model calculation.

It works great!

I am currently traveling in Japan and don't have access to my VIs. Please contact me next week by private e-mail (You can find my e-mail address on the FP of some of my examples posted here, e.g. HERE.

0 Kudos
Message 3 of 5
(3,816 Views)
I was thinking about trying to implement the boolean flag idea for fixed vs. floating parameters in nonlinear fitting.  I would be gratefule to see your code.  Did you use the variant data (for user function) in the nonlinear curve fit LM vi?
0 Kudos
Message 4 of 5
(3,533 Views)

I'd suggest using 'Constrained Nonlinear Curve Fit.vi'.  If the upper and lower limit for a given parameter are the same, then it is constrained to be that value.

 

-Jim

0 Kudos
Message 5 of 5
(3,512 Views)