forum.alglib.net
http://forum.alglib.net/

How to use Levenberg-Marquardt
http://forum.alglib.net/viewtopic.php?f=2&t=535
Page 1 of 1

Author:  jkh13 [ Tue Feb 07, 2012 3:22 pm ]
Post subject:  How to use Levenberg-Marquardt

Hi, I am trying to use the C# implementation of LM and I got a bit confused about how it is supposed to be set up. I have looked at the sample code for the basic Vector of functions version: http://www.alglib.net/translator/man/manual.csharp.html#example_minlm_d_v

From what I gather it is working out what values x[0] and x[1] should be for the following two equations:

y0 = 10 * (x[0]+3)^2
y1 = (x[1]-3)^2

with starting parameters x[0] = 0 and x[1] = 0.

I don't see how the result of x[0] = -3 and x[1] = 3 is being calculated however. Surely you must have a value for y as an observed value to input to the algorithm solve? Furthermore shouldn't there be a known parameter for instance a time parameter for the two equations? How would you be able to optimise to find x[0] and x[1] with the function vector:

y0 = 10* (x[0]+3) ^ 2 * time
y1 = (x[1]-3)^2 * time

Using the observed y values at a certain time?

Author:  Sergey.Bochkanov [ Wed Feb 08, 2012 11:25 am ]
Post subject:  Re: How to use Levenberg-Marquardt

There are two settings for the Levenberg-Marquardt algorithm:
1. minimization of G(x)=f1(x)^2+f2(x)^2+...+fm(x)^2
2. minimization of G(x)=(f(x,point1)-y1)^2+(f(x,point2)-y2)^2+...+(f(x,pointm)-ym)^2

First case is generic optimization problem statement (M different functions, reduce down to zero), second one - is a nonlinear fitting problem (all functions are same, try to fit prescribed function values). (1) is more general, while (2) is the problem you actually solve when you want to process experimental data. ALGLIB supports both types of problems: (1) by minlm subpackage, (2) by lsfit subpackage.

Author:  jkh13 [ Thu Feb 09, 2012 12:15 am ]
Post subject:  Re: How to use Levenberg-Marquardt

Great! that looks like what I need. Just one more quick question. I looked over the example here: http://www.alglib.net/translator/man/manual.csharp.html#example_lsfit_d_nlf and just wanted to confirm my understanding over how it works.

x are the observed parameters (i.e. the ones we know)
y is the observed result of the function
c is the unknown function.

I was wondering how to put in more than one function and optimise simultaneously. For instance if I wanted to solve the following two equations:

f(x) = exp(-c[0]*x[0]^c[1])
f(x) = exp(-c[1]*x[1]^c[0])

how would I solve this? Is there a way I can pass in a vector of functions like in: http://www.alglib.net/translator/man/manual.csharp.html#example_minlm_d_v
and also pass in an array of arrays for y to plug in the results for multiple functions?

Author:  Ray [ Tue Jun 19, 2012 5:30 pm ]
Post subject:  Re: How to use Levenberg-Marquardt

Hi jkh13! x is the argument of your fitting curve. For example, if one measures Voltage U over the current I, so I is x[0], U is y and R is the parameter c[0] one have to determine. So the aim is to find R, for which U=RI fits the measured points in the least square sense.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/