forum.alglib.net http://forum.alglib.net/ |
|
minlbfgs_numdiff and the likelihood function [solved] http://forum.alglib.net/viewtopic.php?f=2&t=858 |
Page 1 of 1 |
Author: | andmon [ Tue May 28, 2013 8:23 pm ] |
Post subject: | minlbfgs_numdiff and the likelihood function [solved] |
Hi all, I would like to find the minimum of a likelihood function using minlbfgs_numdiff (numerical differentiation). Clearly, my function depends on an array of data (vvv[]). I do not understand why it ends up in an infinite loop. Here is the driver I have created. Have you got any suggestions, please? Best, A Code: void function1_func(const real_1d_array &x, double &func, void *ptr)
{ int i; double a=0; double s = 0; double e=0; double err=0; for(i = 0; i<10; i++) { e= vvv[i]-x[0]; a= -0.5*log(2*PI)-0.5*(log(x[1])+(e*e)/x[1]); s=s+a; } func= (s); } |
Author: | Sergey.Bochkanov [ Wed May 29, 2013 9:46 am ] |
Post subject: | Re: minlbfgs_numdiff and the likelihood function |
The most likely reason is that your function is not defined at x[1]<=0 and is not bounded from below at x=0. So, it does not have clear defined global minimum. So, either: * L-BFGS algorithm accidentally steps into x[1]<0 and fails (eternal loop is a possible failure scenario) * L-BFGS algorithm eternally explores sequence of increasingly better x[], with x[1]->0. I recommend you to use BLEIC algorithm with boundary constraint x[1]>=eps where eps is some small number. |
Author: | andmon [ Thu May 30, 2013 7:21 pm ] |
Post subject: | Re: minlbfgs_numdiff and the likelihood function |
Thanks for your reply. Actually I fixed the code simply changing "func(s)" to "func(-s)" and everything works. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |