[R] Optimize multiple variable sets
Hans W Borchers
hwborchers at googlemail.com
Mon Dec 6 19:03:05 CET 2010
peter dalgaard <pdalgd <at> gmail.com> writes:
>
> On Dec 6, 2010, at 15:15 , Jonathan P Daily wrote:
>
> > Correct me if I'm wrong, but isn't the minimal x value in your example
> > the same regardless of what positive coefficient you apply to x? If that
> > is the case, you would expect the same min(x) for each iteration.
> >
> > i.e. in the interval [0,1] the minimum x value of x^2 + x is the same as
> > x^2 + 100000000*x, at x = 0.
>
> You're wrong --- slightly. The returned $minimum is the x, the y is
> $objective. But the interval given doesn't bracket the minimum, as you'll
> clearly see if you put int=c(-10,10). The only puzzling bit is that
> optimize() doesn't actually return the left endpoint, but rather the first
> evaluation point inside the interval. The rather wide tolerance of
> .Machine$double.eps^0.25 == 0.0001220703 probably plays a role in this.
'optimize', as other golden section search algorithms, never returns one of
the endpoints. So to speak, they avoid evaluating the function at the end
points of the interval. An advantage is that the function value at one of
these points can be NA or Inf. Of course, with "tol=.Machine$double.eps"
you will get closer.
Hans Werner
More information about the R-help
mailing list