topic Re: Fitting small data with a lorentzian curve in LabVIEW
https://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369323#M991958
<BLOCKQUOTE><HR /><LI-USER uid="349543"></LI-USER> wrote:<BR /><P> </P><P><SPAN>"What is the Y-range of your data? if it is very small, it prematurely thinks it is converged even if it is not. In this case, you MUST wire the stdev input with an array of equal size as your data, initialized with value appropriate for your data."</SPAN></P><P> </P><P> </P><HR /></BLOCKQUOTE><P>Where did you get this quote? I don't know the details of LabVIEW's implementation of LM, so I don't know if the "convergence criteria" are "absolute" or "relative" scaled. Note that there is a "Weight" input which could be used to normalize your data. Try taking the Standard Deviation of your data and making the Weight an initialized Array of size N whose values are 1/SD, which might be what the quote is recommending.</P><P> </P><P>Bob Schor</P>Wed, 16 Nov 2016 13:56:30 GMTBob_Schor2016-11-16T13:56:30ZFitting small data with a lorentzian curve
https://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369270#M991946
<P>Hello,</P><P> </P><P>as described above I'm trying to fit some measurements with a lorentzian curve. Currently I'm using the Nonlinear Curve Fit Vi. I will attach everything that is needed, since at the moment I'm just playing around.</P><P> </P><P>My Problem is that the amplitudes are in the range of 1E-12 to 1E-9.</P><P>Now I found this:</P><P><SPAN>"What is the Y-range of your data? if it is very small, it prematurely thinks it is converged even if it is not. In this case, you MUST wire the stdev input with an array of equal size as your data, initialized with value appropriate for your data."</SPAN></P><P> </P><P><SPAN>I guess my Y-range is very small, but I don't get the rest of the quote. Since the Vi doesn't have a stdev input?</SPAN></P><P> </P><P><SPAN>I swapped the LavMar with the bounded LavMar and switched it to TRDL. It actually generates a good fit until you put the offset to 30 or 0.5. So neither is really giving me what I would like to have.</SPAN></P><P><SPAN> </SPAN></P><P><SPAN> </SPAN></P><P><SPAN>I have attached every needed VI.</SPAN></P><P><SPAN>"Messung mit Fit.vi" is the one that you need to start. I know the code doesn't look pretty. As you can see it generates values for a lorentzian curve, with hardcoded values.</SPAN></P><P><SPAN>"Ansprechbarer Lorentz-Fit.vi" is the Vi where my LavMar is implemented.</SPAN></P><P><SPAN>"Lorentzfunktion.vi" is my Model for the lorentzian function.</SPAN></P><P><SPAN>The last VI isn't important, but it's needed since I use it.</SPAN></P><P> </P><P> </P><P><SPAN>Greetings</SPAN></P>Wed, 16 Nov 2016 10:32:38 GMThttps://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369270#M991946Vermax2016-11-16T10:32:38ZRe: Fitting small data with a lorentzian curve
https://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369279#M991949
<P>Ok what I now did is just multiplying my Y-Values with 1E6 and dividing the Y-Values after LavMar. Since the characteristic is given by the parameter that doesn't change with the scale it should work like that, but is their another way? Since It will also increase the noise.</P><P> </P>Wed, 16 Nov 2016 11:06:33 GMThttps://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369279#M991949Vermax2016-11-16T11:06:33ZRe: Fitting small data with a lorentzian curve
https://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369323#M991958
<BLOCKQUOTE><HR /><LI-USER uid="349543"></LI-USER> wrote:<BR /><P> </P><P><SPAN>"What is the Y-range of your data? if it is very small, it prematurely thinks it is converged even if it is not. In this case, you MUST wire the stdev input with an array of equal size as your data, initialized with value appropriate for your data."</SPAN></P><P> </P><P> </P><HR /></BLOCKQUOTE><P>Where did you get this quote? I don't know the details of LabVIEW's implementation of LM, so I don't know if the "convergence criteria" are "absolute" or "relative" scaled. Note that there is a "Weight" input which could be used to normalize your data. Try taking the Standard Deviation of your data and making the Weight an initialized Array of size N whose values are 1/SD, which might be what the quote is recommending.</P><P> </P><P>Bob Schor</P>Wed, 16 Nov 2016 13:56:30 GMThttps://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369323#M991958Bob_Schor2016-11-16T13:56:30ZRe: Fitting small data with a lorentzian curve
https://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369347#M991969
<P><A href="http://forums.ni.com/t5/LabVIEW/fitting-with-Lorentzian-curve/td-p/285300" target="_blank">http://forums.ni.com/t5/LabVIEW/fitting-with-Lorentzian-curve/td-p/285300</A></P><P> </P><P>Thats the link.</P><P> </P><P>There is only 1 measurement per datapoint. So I can't calculate the SD for every Point. I could do it over the whole measurement, but isn't that pointless? Since the array will have the same value for every datapoint?</P>Wed, 16 Nov 2016 14:37:51 GMThttps://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369347#M991969Vermax2016-11-16T14:37:51ZRe: Fitting small data with a lorentzian curve
https://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369369#M991977
<P>No, it is not pointless. Yes, it <U>is</U> scaling it up, which is <U>not</U> what "weight" is intended to do (it is, indeed, intended to let you say "These points are measured extremely accurately compared to those points, so weigh them more heavily when fitting the function"). You are trying to "solve a different problem" (which depends on knowing the inner workings of the LM algorithm, so it's a bit of guesswork whether this makes sense at all).</P><P> </P><P>The LM algorithm is an iterative "converging" algorithm that "crawls" towards the "best" answer, usually defined as the one with the closest fit to the data. However, at some point in the process, you might be comparing Solution 1 with Solution 2, and find that (a) both solutions fit almost equally well, differing by, say, .0000000001, and (b) Solution 1, itself, differs from Solution 2 by a "trivial" amount, say .0000000001. But if the data are such that the parameters start small, you might reach Condition (b) too early unless you scale the data up in some "reasonable" manner. This, I think, is what is being recommended.</P><P> </P><P>The (old) post from 2005 that you referenced noted that the LM algorithm had been "fixed" in LabVIEW 8. I'm assuming you are using a much more recent version, so this whole issue might be moot ...</P><P> </P><P>Bob Schor</P>Wed, 16 Nov 2016 15:13:44 GMThttps://forums.ni.com/t5/LabVIEW/Fitting-small-data-with-a-lorentzian-curve/m-p/3369369#M991977Bob_Schor2016-11-16T15:13:44Z