Showing results for 
Search instead for 
Did you mean: 

Fitting an Optimal Curve and Finding Variables

Hi all,


I have measured data and a (non-linear?) function which describes the data.




I want to fit a curve to the measured data to determine an optimal set of values for the independent variables K, h and p1.


I have been given a solution which uses gradient descent method (i.e. partial derivatives) and aims at minimising some gradient error function.


I was thinking that I could do this much more easily using perhaps the Levenberg-Marquardt VI which I have read a bit about in the forums.


I have no idea how to tackle this problem with the equation that I'm using.


I hope that somebody can help me.


Much appreciated.



0 Kudos
Message 1 of 23

Hi Battler,


Could you please re-post your equation?   The equation figure is difficult to identify.


You might want to start from the nonlinear curve fit VI examples which listed in Nonlinear Curve Fit VI help.


Best Regards,


0 Kudos
Message 2 of 23

Hi Michael,


Thanks for your response.




I am currently looking at the non-linear curve fit.  I do not understand the dimensions of my problem and how to go about it. 


I even dont really understand the basic principles.


Help is Greatly appreciated.



0 Kudos
Message 3 of 23


The previous equation wasn't quite correct.


How to go about it and the basic principles of non-linear curve fitting.


What are the dimensions of the problem?  Is it greater than 1D or 2D?  I need to derive p1, k and h.


As you can see my equation is an infinite sum.  Is this ok?


Thanks again.

0 Kudos
Message 4 of 23

An example of actual measured data is:


a =          pa =

2.5          320

5             245

7.5          182

10           162

12.5        168

15           152

0 Kudos
Message 5 of 23

Have you looked at the non-linear curve fitting examples shipped with LV?


They're a pretty good starting point.  All you need is to develop a VI which takes an array of your variables and calculates the result.  The Lev-Mar framework does the rest for you.



0 Kudos
Message 6 of 23

I have looked at the shipped example.


Do I need to create a VI which contains my equation?  It contains an infinite summation.


How do I go about building the equation?  Will I pass a 2D array??

0 Kudos
Message 7 of 23

If you are unable to express your equation, then it was perhaps a bit premature of you to post a question on non-linear optimisation of said equation I think.


Hopefully someone can help you with that.



0 Kudos
Message 8 of 23

function snippet.png


Is that correct?  I've gone with a summation of 100 iterations.  Could I use a while loop?

0 Kudos
Message 9 of 23

As battler. is about to figure out for himself, I am not a big fan of estimating infinite series by first N terms, I prefer to wait for two consecutive "small" terms.  He will most likely choose to wait for a single small term, but some series can trick you when either the even or odd terms are always small.  Here is an example.  The steps are the same as any other non-linear fit, just a little more effort to find f(x,a).  I'll let the partial derivatives slide in this case.



Message Edited by Darin.K on 02-12-2010 03:04 PM
Download All
Message 10 of 23