help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fminsearch does not move


From: Olaf Till
Subject: Re: fminsearch does not move
Date: Thu, 11 Oct 2012 08:11:54 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

On Wed, Oct 10, 2012 at 05:37:26PM +0200, Martijn Brouwer wrote:
> Hi,
> I am trying to do a 2D non-linear least squares optimisation. I have
> image data and would like to subtract a profile that is defined using 6
> parameters. For 1D data I always use leasqr, but as far as I could
> determine fminsearch or fmins are the best options for optimisation on a
> 2D domain.

You have 6 parameters and you choose to use a scalar objective
function. The distances from your profile seem to be calculated from
one-dimensional values. What then do you mean by "2D optimization"?
And what made you think that fminsearch is best for this?

> The problem I encounter is that the final fitting parameters returned by
> fminsearch are identical to the initial parameters. What is wrong here?

fminsearch by default uses a gradient-free algorithm, which is usually
inferior to a gradient-based one. Your objective function seems to be
continuous, so I'd see no reason to use a gradient-free algorithm.

> Martijn
> 
> 
> function z=profile(xx, yy, rr, p)
>   z = p(1)*(1 + p(2)*xx + p(3)*yy + p(4)*xx.^2 +
> p(5)*yy.^2).*exp(rr*p(6));
> end
> 
> f = @(p) sum(sum((QImg - profile(xx,yy,r, p)).^2))/n;

You could use this objective function with sqp or the default
algorithm of nonlin_min. A possibly better option is to use the matrix
of differences

QImg - profile(xx,yy,r, p)

directly as a model function and use the default algorithm of
nonlin_residmin. leasqr uses the same algorithm but needs the
specification of a matrix of observations, which would have to be set
to all zeros in your case.

> p0=[1, sx, sy, sx2, sy2, 0];
> 
> z0 = profile(xx,yy,r, p0);
> 
> p = fminsearch(f, p0);
> 
> 
> xx, yy, and r are predefined matrices with the x, y and radial
> coordinates of the pixels. From commandline I can evaluate f(p), but
> apparently fmisearch has a problem with my function.

BTW you have sent the same message 3 times yesterday.

Regards, Olaf

-- 
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]