LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

Exponential Best Fit Is Off?

Hey again, wonderful forumers!

So, my lab advisor came back from her trip to Italy… turns out using the Leven-Marquart fitting process is okay, so we turned our attention to the exponential fitting process.

As we inspected this element further, we found out that there’s something fishy going on with our best fit line. I take theoretical Lorentzian data and plug said points in for tau in an exponential generation process. After generating the exponential data, I add Gaussian noise, and then pull THAT data into the standard exponential fit VI. The resulting best fit line is nowhere near the curve of original theoretical data, which is what I was predicting. Am I doing something wrong or is the data not appropriate for this fitting process? Peers here on my end have tried fitting the same data in different programs, and their processes work… so perhaps there’s something screwed up in my code!

I’ve included the main VI and a few SubVIs with this message.

Any help or comments would be appreciated.

Sincere thanks,
Vari

Message 1 of 6
(1,865 Views)

Re: Exponential Best Fit Is Off?

I am curious why you would take the absolute value before and after squaring in your ChiSquared subVI. 😮

Whatever comes out of your FOR loop does no look like a lorentzian. Inside the while loop, the fit to an exponential looks ok.

LabVIEW Champion. It all comes together in GCentral
What does "Engineering Redefined" mean??
Message 2 of 6
(1,849 Views)

Re: Exponential Best Fit Is Off?

I built most of this code while I was frustratedly trying to learn labview. XD I guess that's something that just got carried along. -fixes-

Are you saying the red data (the noisy data) doesn't look like a Lorentzian? I've upped the noise a lot to demonstrate the exponential problem, and the difference between the orange dotted line (theoretical exp) and the green line (best fit exp) on the EXP graph below.

Message 3 of 6
(1,841 Views)

Re: Exponential Best Fit Is Off?

I've included a picture here for the exponential data and 'fits'.

The red noisy data is an example of what I'll be collecting... the white line is a fit done by method of Levenberg-Marqaurdt. I like how that fits. 😄 The green line is the best fit resulting from the Exponential Fit VI, using least squares method. I guess, I didn't expect the difference to be as large as it is... if we get a lot of noise in our samples, the resulting fit is going to be AWFUL since we're working with super small numbers.

Anything to say on the matter or are me and my lab just crazy?

Message 4 of 6
(1,786 Views)
Solution
Accepted by topic author Varinem

Re: Exponential Best Fit Is Off?

@Varinem wrote:

Anything to say on the matter or are me and my lab just crazy?

You have a pretty old LabVIEW version and the "unconstrained exponential fit" you are using is not directly supported, according to the context help. Wire a "refine=TRUE" to the lower input and things look better.

Substituting the toplevel exponential fit from the palette gives excellent results.

(While you are at it, please get rid of these stupid detours via dynamic data. Remove the "to dynamic data" and "merge signal" nodes. A simple "built array" works just fine).

LabVIEW Champion. It all comes together in GCentral
What does "Engineering Redefined" mean??
Message 5 of 6
(1,769 Views)

Re: Exponential Best Fit Is Off?

Very much thanks, Alten. I'd give you multiple kudos if I could.
And I'll be sure to fix the rest as well.

Message 6 of 6
(1,743 Views)