I work with MATLAB R2008b. I am interested in calculating the central numerical (finite differences) hessian for a given function. In MATLAB's optimization toolbox help, says that MATLAB calculates numerical hessians however it does not say if there is a function that does exactly that.
Does anyboby know the name of this function, if it exists, or any place where I can download such a function?
Thanks in advance
Find derivest and its cousin, hessian, on the file
exchange. It does exactly what you ask for.
http://www.mathworks.com/matlabcentral/fileexchange/13490
fun = @(xy) exp(-sum(xy.^2));
hessian(fun, [0,0])
ans =
-2 0
0 -2
John
My function is a likelihood function, therefore I have to pass to the function the data points as well. Can this be done with DERIVEST?
Manthos
Sure. A function handle does this with no problem.
Your call might look vaguely like this...
H = hessian(@(x) likfun(x,datapoints,otherstuff),x0);
As long as the variables datapoints and otherstuff are
defined in the workspace, matlab will pass in their
values to the code. However the hessian code sees
this anonymous function handle as purely a function
of the variable x only.
John