# 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.

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: minlbfgs_numdiff and the likelihood function [solved]Posted: Tue May 28, 2013 8:23 pm

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

 Post subject: Re: minlbfgs_numdiff and the likelihood functionPosted: Wed May 29, 2013 9:46 am

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

 Post subject: Re: minlbfgs_numdiff and the likelihood functionPosted: Thu May 30, 2013 7:21 pm

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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 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 forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for: