00001 00011 #include "fvar.hpp" 00012 00022 double log_density_negbinomial(double x,double mu,double tau) 00023 { 00024 if (tau-1.0<0.0) 00025 { 00026 cerr << "tau <=1 in log_negbinomial_density " << endl; 00027 ad_exit(1); 00028 } 00029 double r=mu/(1.e-120+(tau-1.0)); 00030 return gammln(x+r)-gammln(r)-gammln(x+1) 00031 +r*log(r)+x*log(mu)-(r+x)*log(r+mu); 00032 } 00033 00043 double density_negbinomial(double x,double mu,double tau) 00044 { 00045 if (tau-1.0<0.0) 00046 { 00047 cerr << "tau <=1 in negbinomial_density " << endl; 00048 ad_exit(1); 00049 } 00050 double r=mu/(1.e-120+(tau-1.0)); 00051 return exp(gammln(x+r)-gammln(r)-gammln(x+1) 00052 +r*log(r)+x*log(mu)-(r+x)*log(r+mu)); 00053 } 00054 00061 double log_density_poisson(double x,double mu) 00062 { 00063 return -mu+x*log(mu)-gammln(x+1); 00064 }
Generated on Tue Mar 8 2016 19:51:30 for ADMB Documentation by 1.8.0 |