LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

nonLinear Fit starting points

I am using in CVI 8.5.1 and calling the function NonLinearFitWithMaxIters().  When I did it for 2 coefficients, it solved quickly with a good fit (MSE < 0.1).  When I change two constants in the equation to additional coefficients that need to be solved, the fit is poor.

 

F+C*exp^(a*t) - F*exp^(b*t): solving for F & C alone with known values for a & b was fine.  But fitting for all 4 coefficients based upon the data gathered and the equation is bad

 

Is there a function or method to provide initial starting points for the coefficients?

 

Thank you,

Matt

0 Kudos
Message 1 of 2
(3,286 Views)

Finding initial parameters for fitting nonlinear functions is crucial except in very simple cases with few parameters. The more parameters, the higher the chance the fit will not converge due to even slight mismatches of the start conditions. So what you see is a general problem of nonlinear fitting.

 

One possibility to increase chances is first to analyze the function: where is the maximum, is it possible to determine a half width of lifetime (exponential growth/decrease), and then calculate numerically some characteristics of the data set before starting the fitting procedure: 1st, 2nd derivative etc, and from these information estimate one or two parameters. Sometimes, functions such as PeakDetector may be useful here.

In a second step, still before starting the fitting procedure, one could calculate the difference between the model function (with the initial starting parameters) and the data set, and then inspect this difference: is the maximum of this difference to the left or to the right of your model function? Then adjust the peak position, etc.

 

This is a general and complicated problem, so do not beome desperate: the differences between many commercial programs are exactly how sensitive or tolerant they are, that is, how smart they are to find initial guesses (the fitting precedure is standard)

 

One example: I used to fit Gaussians, with an offset, that makes 4 parameters. It hardly ever worked. Then I decided to determine the offset (usually there is always a region where no signal is to be expected) first, subtract it, and then use the Gaussian with three parameters only, without offset. This worked, most of the time. Then, if ambitious, one could just use these fit results to restart with four parameters...  

 

Good luck,

 

Wolfgang

Message 2 of 2
(3,271 Views)