Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Levenberg-Marquardt Optimization Queston

Subject: Levenberg-Marquardt Optimization Queston

From: Antony zerrar

Date: 22 Jun, 2010 12:36:09

Message: 1 of 2

Hi guys,

I have a data set that I want to fit to the Laplace distribution and have some problems in doing so, however fsolve gives the correct answer. I want to replicate it step by step. The code that I use is:

data = [-1 5 2];
x0=[0 1]';
x(:,1)=x0;
index=1;
n=length(data);
l=0.01;
for i=1:15
    fm = -1/x(2,index);
    fs = -n/x(2,index)+sum(abs(data-x(1,index)))/(x(2,index)^2);
    G = [fm ; fs]; % Gradient Vector
    H = G*G'; % Hessian Vector
    I=eye(2,2);
    x(:,index+1) = x(:,index) - inv(H+l*I)*G;
   LLF(index+1,1) = -n*log(2)-n*log(x(2,index))-sum(abs(data-x(1,index)))/x(2,index);
    index=index+1;
end

Thanks alot!

Subject: Levenberg-Marquardt Optimization Queston

From: Miroslav Balda

Date: 22 Jun, 2010 21:24:07

Message: 2 of 2

"Antony zerrar" <zerrar@yahoo.com> wrote in message <hvqanp$pr8$1@fred.mathworks.com>...
> Hi guys,
>
> I have a data set that I want to fit to the Laplace distribution and have some problems in doing so, however fsolve gives the correct answer. I want to replicate it step by step. The code that I use is:
>
> data = [-1 5 2];
> x0=[0 1]';
> x(:,1)=x0;
> index=1;
> n=length(data);
> l=0.01;
> for i=1:15
> fm = -1/x(2,index);
> fs = -n/x(2,index)+sum(abs(data-x(1,index)))/(x(2,index)^2);
> G = [fm ; fs]; % Gradient Vector
> H = G*G'; % Hessian Vector
> I=eye(2,2);
> x(:,index+1) = x(:,index) - inv(H+l*I)*G;
> LLF(index+1,1) = -n*log(2)-n*log(x(2,index))-sum(abs(data-x(1,index)))/x(2,index);
> index=index+1;
> end
>
> Thanks alot!

Hi Antony,
I'll not comment your code, because I have not study it. It is only a script (not a function) and there is no Levenberg-Marquardt procedure at all. I only can tell you that Laplace distribution is not a smooth function, so there is no gradient at the point mean(x). It may cause some problems when using any gradient method for a fit of parameters of the distribution. Use fminsearch (Nelder-Mead) function instead. If you wish some help, send your experimental data.
Best regards,
Mira

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us