If 'myfunc' is a vector function and can be vectorized in R, then it
is even faster to use the following:
grad.vec - function(x, fn, ..., eps = sqrt(.Machine$double.neg.eps)){
x1 - x + eps * pmax(abs(x), 1)
x2 - x - eps * pmax(abs(x), 1)
(fn(x1, ...) - fn(x2, ...)) / (x1 - x2)
}
Thank you, Dimitris Christos.
Yes, myfunc is a scalar function that needs to be minimized over a
high-dimensional parameter space. I was afraid that there might be no
better way, apart from coding in C. Thanks, Dimitris, for confirming my
fear!
Best regards,
Ravi.
On Thu, 27 Mar 2008, Ravi Varadhan wrote:
Thank you, Dimitris Christos.
Yes, myfunc is a scalar function that needs to be minimized over a
high-dimensional parameter space. I was afraid that there might be no
better way, apart from coding in C. Thanks, Dimitris, for confirming my
fear!
3 matches
Mail list logo