How to use fminunc providing gradient and hessian?

11 views (last 30 days)
MRC
MRC on 2 Feb 2014
Edited: Matt J on 2 Feb 2014
Hi, could you help me in making this code (attached) working? Thanks!

Accepted Answer

Matt J
Matt J on 2 Feb 2014
You need to return the gradient and Hessian
function [val,g,H]=log_lik(theta,ix)
Also, these tolerances look unrealistically small
'TolX',10^-30,'TolFun',10^-30

More Answers (1)

Paul
Paul on 2 Feb 2014
Edited: Paul on 2 Feb 2014
What Matt said and the way you want to calculate the gradient and hessian is not gonna work. since val is just a single value, the function jacobian is not gonna work.
  6 Comments
Matt J
Matt J on 2 Feb 2014
@Paul: Ah! I get it now.
@Cris: If you are setting GradObj and Hessian to 'on' because of Walter's remark here, I think it's too soon. I think you should try with the default gradient and Hessian calculation first and then add your own once you're getting decent optimization results and you just need to make small improvements to speed and accuracy.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by