00001 #include "statsLib.h" 00002 00035 dvariable dpois(const double& k, const prevariable& lambda) 00036 { 00037 RETURN_ARRAYS_INCREMENT(); 00038 dvariable tmp = -k*log(lambda)+lambda + gammln(k+1.); 00039 RETURN_ARRAYS_DECREMENT(); 00040 return tmp; 00041 } 00042 00051 dvariable dpois(const prevariable& k, const prevariable& lambda) 00052 { 00053 RETURN_ARRAYS_INCREMENT(); 00054 dvariable tmp = -k*log(lambda)+lambda + gammln(k+1.); 00055 RETURN_ARRAYS_DECREMENT(); 00056 return tmp; 00057 } 00058 00067 dvariable dpois(const dvector& k, const dvar_vector& lambda) 00068 { 00069 RETURN_ARRAYS_INCREMENT(); 00070 int i; 00071 int n = size_count(k); 00072 dvariable nll=0; 00073 for(i = 1; i <= n; i++) 00074 { 00075 // nll -= k(i)*log(lambda(i))+lambda(i)+gammln(k(i)+1.); 00076 nll += -k(i)*log(lambda(i))+lambda(i)+gammln(k(i)+1.); 00077 } 00078 RETURN_ARRAYS_DECREMENT(); 00079 return nll; 00080 } 00081 00082
Generated on Tue Mar 8 2016 19:51:32 for ADMB Documentation by 1.8.0 |