Message-ID: <87AAD28D-E1DF-400D-8717-92ACB6166286@xs4all.nl>
Date: 2009-05-24T13:27:35Z
From: Berend Hasselman
Subject: using optimize() correctly ...
In-Reply-To: <4A193C85.5020804@gmail.com>
On 24-05-2009, at 14:24, Esmail wrote:
> Hello Berend,
>
> Berend Hasselman wrote:
>> Your function is not unimodal.
>> The help for optimize states: "If f is not unimodal, then
>> optimize() may approximate a local, but perhaps
>> non-global, minimum to the same accuracy."
>
> Ah ok, I didn't read the manual page carefully enough.
>
> Do you know if R has a function to find the global maximum/minimum
> of a
> function of x over a given interval?
>
If you do
resopt <- optim(-5,f, method="SANN",control=list(fnscale=-1))
you will get the global maximum. SANN: simulated annealing. But
starting in -4 takes you to the local maximum.
But the help for optim recommends optimize for one-dimensional
maximization.
As far as I know there is no general foolproof method for finding a
global optimum except trying different initial points.
No method can really replace one's own knowledge about a function.
Berend
btw. i am away during this week so i won't be replying.