码迷,mamicode.com
首页 > 其他好文 > 详细

Levenberg–Marquardt algorithm

时间:2015-06-12 17:21:27      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:


技术分享

技术分享


function [x,minf] = minLM(f,x0,beta,u,v,var,eps)
format long;
if nargin == 6
    eps = 1.0e-6;
end
S = transpose(f)*f;
k = length(f);
n = length(x0);
x0 = transpose(x0);
A = jacobian(f,var);
tol = 1;

while tol>eps
    Fx = zeros(k,1);
    for i=1:k
        Fx(i,1) = Funval(f(i),var,x0);
    end
    Sx = Funval(S,var,x0);
    Ax = Funval(A,var,x0);
    gSx = transpose(Ax)*Fx;
    Q = transpose(Ax)*Ax;
    
    while 1
        dx = -(Q+u*eye(size(Q)))\gSx;

        x1 = x0 + dx;
        for i=1:k
            Fx1(i,1) = Funval(f(i),var,x1);
        end
        Sx1 = Funval(S,var,x1);
        tol = norm(dx);
        if tol<=eps
            break;
        end

        if Sx1 >= Sx+beta*transpose(gSx)*dx
            u = v*u;
            continue;
        else
            u = u/v;
            break;
        end
    end
    x0 = x1;
end
x = x0;
minf = Funval(S,var,x);
format short;


Levenberg–Marquardt algorithm

标签:

原文地址:http://blog.csdn.net/tanmengwen/article/details/46473077

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!