LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fit tolerance of nonlinear lev-mar?

I'm using the non-linear lev-mar vi to fit an exponential. At first it was returning one of my initial guesses (damping) without changing it. My initial guess was pretty good, but could have been improved. I noticed two undocumented constants (0.01) in the lev-mar vi, and changed them both to 0.000001. The fit worked much better. What are these constants? Is there a better way to tighten (or specify, in general) the fit criteria on the lev-mar?
0 Kudos
Message 1 of 2
(2,606 Views)
Yes, this is an odd hardwired constant that is only appropriate if you actually wire the standard deviation array. It should only be in one spot and it is actually 0.001. I am talking about the constant at the bottom center of the stock "nonlinear Lev-Mar Fit.vi", feeding into the loop.

If the standard deviation is NOT wired, it is assumed to be 1 and chisquared is a measure of the variance betweeen data and fit. This blows up if your data is very small.

Since the function using the initial parameters is already within 0.001 of the data, it is immediately treated as converged as you noticed.

Solution:
(1) Wire the standard deviation! Initialize an array with the same size as your data and a value set to your estimated standard deviation. (e.g
. 0.01% of max-min of your data, or amplitude of least significant bit, etc.)

(2) Rewrite the stock VI as you did (Don't touch the lamda! lower only the single constant at bottom center!). Make sure to rename it and don't save it in vi.lib or it won't survive version upgrades.
0 Kudos
Message 2 of 2
(2,606 Views)