forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 11:50 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to use Levenberg-Marquardt
PostPosted: Tue Feb 07, 2012 3:22 pm 
Offline

Joined: Tue Feb 07, 2012 2:52 pm
Posts: 3
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?


Top
 Profile  
 
 Post subject: Re: How to use Levenberg-Marquardt
PostPosted: Wed Feb 08, 2012 11:25 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
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.


Top
 Profile  
 
 Post subject: Re: How to use Levenberg-Marquardt
PostPosted: Thu Feb 09, 2012 12:15 am 
Offline

Joined: Tue Feb 07, 2012 2:52 pm
Posts: 3
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?


Top
 Profile  
 
 Post subject: Re: How to use Levenberg-Marquardt
PostPosted: Tue Jun 19, 2012 5:30 pm 
Offline

Joined: Tue Jun 19, 2012 9:27 am
Posts: 10
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group