topic Constraining values in non-linear curve fit in LabVIEW
https://forums.ni.com/t5/LabVIEW/Constraining-values-in-non-linear-curve-fit/m-p/4156663#M1199549
<P>Hi all,</P>
<P>I am trying to use the non-linear curve fit function Lev-mar IV to try to find a best fit line for some data which is modeled by an equation which contains some complex numbers and hyperbolic trig functions. The best fit cure always returns to me as a nearly horizontal line. I think i would be able to solve this problem If I could place upper and lower bounds on two of the three variables the equation is optimizing, and if I could reduce the "step size" the function goes at when optimizing.</P>
<P> </P>
<P>Further info:</P>
<P>I believe that the step size of the function is too large as when I run the program with the optimization function iterating once with very high tolerance, the input values are not returned to me; instead I receive values that have been off by as much as 250. Additionally, these values are negative, and the real life phenomenon that the model represents cannot be negative.</P>
<P>Thanks for your time</P>Thu, 10 Jun 2021 18:03:42 GMTAlexF34492021-06-10T18:03:42ZConstraining values in non-linear curve fit
https://forums.ni.com/t5/LabVIEW/Constraining-values-in-non-linear-curve-fit/m-p/4156663#M1199549
<P>Hi all,</P>
<P>I am trying to use the non-linear curve fit function Lev-mar IV to try to find a best fit line for some data which is modeled by an equation which contains some complex numbers and hyperbolic trig functions. The best fit cure always returns to me as a nearly horizontal line. I think i would be able to solve this problem If I could place upper and lower bounds on two of the three variables the equation is optimizing, and if I could reduce the "step size" the function goes at when optimizing.</P>
<P> </P>
<P>Further info:</P>
<P>I believe that the step size of the function is too large as when I run the program with the optimization function iterating once with very high tolerance, the input values are not returned to me; instead I receive values that have been off by as much as 250. Additionally, these values are negative, and the real life phenomenon that the model represents cannot be negative.</P>
<P>Thanks for your time</P>Thu, 10 Jun 2021 18:03:42 GMThttps://forums.ni.com/t5/LabVIEW/Constraining-values-in-non-linear-curve-fit/m-p/4156663#M1199549AlexF34492021-06-10T18:03:42ZRe: Constraining values in non-linear curve fit
https://forums.ni.com/t5/LabVIEW/Constraining-values-in-non-linear-curve-fit/m-p/4156671#M1199552
<P>As a starting point, you can try the <A href="https://zone.ni.com/reference/en-XX/help/371361R-01/gmath/con_nonlin_curve_fit/" target="_self">Constrained Nonlinear Curve Fit VI</A> , which lets you define parameter bounds. Still maybe you should carefully analyze the problem, for example are some parameters highly correlated? How do the partial derivatives look like? Sometimes you can reparametrize the model differently for a more stable fit.</P>
<P> </P>
<P>Feel free to attach your Code and some typical data.</P>Thu, 10 Jun 2021 18:42:05 GMThttps://forums.ni.com/t5/LabVIEW/Constraining-values-in-non-linear-curve-fit/m-p/4156671#M1199552altenbach2021-06-10T18:42:05ZRe: Constraining values in non-linear curve fit
https://forums.ni.com/t5/LabVIEW/Constraining-values-in-non-linear-curve-fit/m-p/4156678#M1199556
<P>I've attached some code for you to look at. the file reflection with two windows is the program and the other file is for reference for the optimization function. I cannot attach any data sets because most of my data is spreadsheets with thousands of rows, the file is too large.</P>Thu, 10 Jun 2021 18:56:15 GMThttps://forums.ni.com/t5/LabVIEW/Constraining-values-in-non-linear-curve-fit/m-p/4156678#M1199556AlexF34492021-06-10T18:56:15ZRe: Constraining values in non-linear curve fit
https://forums.ni.com/t5/LabVIEW/Constraining-values-in-non-linear-curve-fit/m-p/4156680#M1199558
<P>Thanks. I will probably not weed through all that messy code.</P>
<P> </P>
<P>All I need is:</P>
<OL>
<LI>the model VI (currently missing)</LI>
<LI>a set of typical parameters and d2 wired to the "data" input (are there really only three? Are the control values reasonable?). Is the data currently in the graphs typical?</LI>
<LI>and the typical X range.</LI>
</OL>
<P> </P>
<P>If you simulate the data using the parameter guesses, how similar is it to the experimental data?</P>Thu, 10 Jun 2021 19:15:03 GMThttps://forums.ni.com/t5/LabVIEW/Constraining-values-in-non-linear-curve-fit/m-p/4156680#M1199558altenbach2021-06-10T19:15:03Z