octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #57136] fminsearch function diverges despite g


From: Rik
Subject: [Octave-bug-tracker] [bug #57136] fminsearch function diverges despite good starting point
Date: Mon, 28 Oct 2019 21:39:00 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

Update of bug #57136 (project octave):

              Item Group:        Incorrect Result => Matlab Compatibility   
        Operating System:                  Mac OS => Any                    

    _______________________________________________________

Follow-up Comment #3:

I think you need to modify your objective function.  It can return complex
values which I believe is interfering with the algorithm.

If I run your problem as you have created it, I get this result


[x, fval, flag, output] = fminsearch (@(x) loglik_LEVD (x, data), x0)
x =

  -5.6748e+07  -7.4920e+04

fval =  Inf + 6e+01i
flag = -1
output =

  scalar structure containing the fields:

    iterations = 14
    funcCount = 38
    algorithm = Nelder-Mead simplex direct search
    message = Exceeded target...quitting



But if I take the real part of your objective function, then I get the same
answer as Matlab.


[x, fval, flag, output] = fminsearch (@(x) real (loglik_LEVD (x, data)), x0)
x =

   2.0180e+07   2.5536e+06

fval = 326.86
flag = 1
output =

  scalar structure containing the fields:

    iterations = 32
    funcCount = 70
    algorithm = Nelder-Mead simplex direct search
    message = Algorithm converged.  Simplex size 9.0664e-05 <= 1.0000e-04 and
step in function value 4.1412e-06 <= 1.0000e-04


The documentation for fminsearch from Matlab
(https://www.mathworks.com/help/matlab/ref/fminsearch.html) states this about
the objective function "fun": "Function to minimize, specified as a function
handle or function name. fun is a function that accepts a vector or array x
and returns a real scalar f (the objective function evaluated at x)."

The result must be a real scalar.  The fact that Matlab seems to work with
this example suggests that they call real() internally in fminsearch to
discard the imaginary part of any objective function evaluation.  We could do
that in Octave as well.  I'm changing the Item Group to Matlab Compatibility.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57136>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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