[ADMB Users] Fwd: admb10 64bit has problem?

Johnoel Ancheta johnoel at hawaii.edu
Fri Feb 18 12:15:52 PST 2011


On Fri, 18 Feb 2011, Weihai Liu wrote:

> 

> 
Hi Arni,

> 
> 
Currently I found out there are some unconsistent about using log_negbinomial_density() function for ADMB 10 64 bit.

> 
> 
Following is my testing tpl, it runs ok on my windows admb9 32bit. 3 variant function can agree. But not consistent on ubuntu admb10 64 bit, I am quickly test on your new release windows 64 bit, it has the same issue, not consistent.


> 
> 
The testing function is nll for NB(m,s), which use gammln() built in function, why I build my own version, because at first I found the ADMB builtin log_negbinomial_density() failed on linux admb10 64 bit, so to figure out what cause the problem, I set it up two other alternative functions,see below.


> 
> 
>From my own nllNegativeBinomial(), I have to separate some terms out, then the problem gone. I feel there are some issue on admb10 64 bit, or some issue come from gammln(), since I am not testing it on admb10 32 bit on windows,so not sure the problem is from different version of admb or different bits or combinations.


> 
> 
you can play around by changing the mu,s in NB(mu,s), or get rid of mfexp in the cout to see nll.

> 

> 
> 
GLOBALS_SECTION
> 
 #include "admodel.h"
> 
 const double EPS = 1.e-20;

> 
> 
DATA_SECTION

> 
> 
PARAMETER_SECTION
> 
 init_number junk
> 
 //random_effects_vector junk1(1,2)
> 
 objective_function_value nll

> 
> 
PROCEDURE_SECTION
> 
 dvariable mu=1.;
> 
 dvariable s=1.;

> 
> 
 for(int n=0;n<=20;n++){
> 
   //full negative log likelihood for NB(mu,s)
> 
   cout<<"*catch,mu,s "<<n<<" "<<mu<<" "<<s<<"  nll ";
> 
   cout<< mfexp(-nllNegativeBinomial(double(n),mu,s));  //works both on
> 
admb9(win) 32bit,admb10(linux) 64bit
> 
   cout<<" "<<mfexp(-nllNegativeBinomial2(double(n),mu,s)); //good on
> 
admb9(win) 32bit,fail on admb10(linux) 64bit
> 
   cout<<" "<<mfexp(log_negbinomial_density(double(n),mu,1.+mu/s))<<endl;
> 
//good on admb9(win)32bit,fail on admb10(linux) 64bit
> 
 }
> 
 exit(8);

> 

> 
> 
//following version get consistent results for windows admb9 32bit and linux
> 
admb10 64bit
> 
FUNCTION dvariable  nllNegativeBinomial(double obs,const dvariable& m,const
> 
dvariable& s)
> 
 dvariable nll1=0;dvariable nll2=0;  dvariable nll3=0; dvariable nll=0;
> 
 //nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s))- obs*log(m/(m+s)+EPS)+
> 
gammln(obs+1.);
> 
 nll1= -gammln(obs+s)+ gammln(s)+gammln(obs+1.);
> 
 nll2= - s*log(s/(m+s)+EPS);
> 
 nll3= - obs*log(m/(m+s)+EPS);
> 
 nll=nll1+nll2+nll3;
> 
 return nll;

> 
> 
//following version works for windows admb9 32bit, same as builtin
> 
log_negbinomial_density()
> 
//not good on linux admb10 64bit, failed as log_negbinomial_density(),but
> 
they got somewhat different results
> 
FUNCTION dvariable  nllNegativeBinomial2(double obs,const dvariable& m,const
> 
dvariable& s)
> 
 dvariable nll=0;
> 
 nll= -gammln(obs+s)+ gammln(s)- s*log(s/(m+s)+EPS)- obs*log(m/(m+s)+EPS)+
> 
gammln(obs+1.);
> 
 //nll= -gammln(obs+s)+ gammln(s)- s*(log(s)-log(m+s))-
> 
obs*(log(m)-log(m+s))+ gammln(obs+1.);
> 
 return nll;

> 
> 
weihai

> 


> 
> > 
> -- 
> Weihai Liu
> ~~~~~~~~~~~~~~~~~~~~~~~~
> Quantitative Fisheries Center
> Department of Fisheries & Wildlife
> Michigan State University
> 153 Giltner Hall
> East Lansing, MI 48824
> 
Phone: 517-355-0126
> Email: liuweih at msu.edu 
> http://qfc.fw.msu.edu/weihai
> ~~~~~~~~~~~~~~~~~~~~~~





More information about the Users mailing list