From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-16-2015 01:32 PM
Trying to do a simple 3-exponential decay nonlinear curve fit. I have a copy of this working in other VIs but it doesn't seem to work in this VI. I'm using Altenbach's "scalablemultiexponentialdecay" as a model VI/template. The data I'm trying to fit is a simple series RC decay, yes I realize that shouldn't have 3 exponential components, it's just model data. I am able to fit it with the built in Exponential Fit function from the Math palette, however that only works if the parameter bounds input is wired and with rational constraints. However, I get an error on the nonlinear curve fit that I don't understand (picture is attached) indicating that an INF or NaN is getting in the parameters. I don't see where that's happening...
Any help or questions is appreciated.
Solved! Go to Solution.
12-16-2015 01:45 PM
Edit:
I tried to implement the fit with the 'formula string' version of the nonlinear fit VI, same error.
12-16-2015 01:48 PM
12-16-2015 01:56 PM
I didn't think so, just 0s for the 2nd two exponentials. But, when I replace all the seededes guess with the same outputs as the single exponential fitter, it converges without error. I guess I didn't realize it was that sensitive. Thanks.
12-16-2015 02:40 PM
Next time, try not to leave my name in a diagram comment of the posted model. I have nothing to do with that code! (My code is typically scalable so the model does not need to know the number of exponentials!)
And yes, if a single exponential gives you a reasonable fit, a model with three exponentials will most likely not produce anything meaningful. 😉 That's to be expected.
Also, if you start out with amplitudes of zero, the partial derivatives for all other parameters of that component is also zero, of course because the function does not change no matter what the decay is. With an amplitude of zero, any decay from -inf to +inf gives you an equally good fit. 😄
12-16-2015 02:46 PM
I started with your scalable model, then stripped the scalabilty out of it in case that was causing trouble. I appreciate your scalable model, it's one of the only comprehensible examples I can find about the nonlinear curve fit. Since you're in the thread, what is the "data" input to the Nonlinear Curve Fit VI, where in your scalable example you take your Guess Cluster and convert it to a variant? Is this important? Sometimes I wire it to the NCF VI, sometimes I don't.
I find a multiexponential fit to single exponential data tends to give me an accurate fit but with the amplitudes divided by the # of exponentials and the time constants the same.
I don't know enough about the LM fit to know what the partial derivatives do.
12-16-2015 03:19 PM - edited 12-16-2015 03:20 PM
@afh wrote:
I started with your scalable model, then stripped the scalabilty out of it in case that was causing trouble..
What kind of trouble? Properly used, it should work just fine. 😄
@afh wrote:
what is the "data" input to the Nonlinear Curve Fit VI, where in your scalable example you take your Guess Cluster and convert it to a variant? Is this important?
It is important if the variant data is actually used inside the model. Look at the output of "variant to data". Does it go anywhere? Else it is irrelevant. My model requires it to allow the ability to fit for a subset of all parameters, leaving some untouched by the fitting procedure. Do you understand the code at all?
@afh wrote:
I find a multiexponential fit to single exponential data tends to give me an accurate fit but with the amplitudes divided by the # of exponentials and the time constants the same.
This is pointless, because you have near infinite correllations between the amplitudes. Basically you could be adding two identical exponentials, each with amplitude=0.5. The exact same curve could be reproduced with identical fit quality by making one amplitude 100001 and the other amplitude -100000. Don't fit for more parameters than the data represents! The fitting could even wander towards [Inf+1,-Inf] for the two amplitudes, causing it to blow up on the way. If two parameters are correlated, the change in one parameter can be compensated fully by a change in another parameter, making the result not unique.
This is the main reason my original code was scalable to work for any number of expoentials. Start with one, then two, etc. until the fit quality is within the error of the data. Don't just throw a overparameterized model at it.
In any case, don't leave diagram comments that are no longer appropriate. I am only responsible for the code I write myself and I don't want to take the blame if somebody randomly chops up my code, but leaves my name it. That's not nice.