forum.alglib.net

ALGLIB forum
It is currently Tue Dec 06, 2022 11:34 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: minlbfgs_numdiff and the likelihood function [solved]
PostPosted: Tue May 28, 2013 8:23 pm 
Offline

Joined: Tue May 28, 2013 8:10 pm
Posts: 2
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);
   
}


Last edited by andmon on Thu May 30, 2013 7:22 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: minlbfgs_numdiff and the likelihood function
PostPosted: Wed May 29, 2013 9:46 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 880
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.


Top
 Profile  
 
 Post subject: Re: minlbfgs_numdiff and the likelihood function
PostPosted: Thu May 30, 2013 7:21 pm 
Offline

Joined: Tue May 28, 2013 8:10 pm
Posts: 2
Thanks for your reply. Actually I fixed the code simply changing "func(s)" to "func(-s)" and everything works.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group