00001 /* 00002 * $Id$ 00003 * 00004 * Author: David Fournier 00005 * Copyright (c) 2008-2012 Regents of the University of California 00006 */ 00011 #include <fvar.hpp> 00012 00021 dvariable log_gamma_density(const prevariable& _x,double r, double mu) 00022 { 00023 prevariable& x= (prevariable&)(_x); 00024 00025 return r*log(mu) + (r-1)*log(x)-mu*x-gammln(r); 00026 } 00027 00036 dvariable log_gamma_density(const dvariable& _x,const dvariable& _r, 00037 const dvariable& _mu) 00038 { 00039 prevariable& x= (prevariable&)(_x); 00040 prevariable& r= (prevariable&)(_r); 00041 prevariable& mu= (prevariable&)(_mu); 00042 return r*log(mu) + (r-1)*log(x)-mu*x-gammln(r); 00043 } 00044 00054 dvariable gamma_density(const prevariable& _x,double r, double mu) 00055 { 00056 prevariable& x= (prevariable&)(_x); 00057 00058 return exp(r*log(mu) + (r-1)*log(x)-mu*x-gammln(r)); 00059 } 00068 dvariable gamma_density(const dvariable& _x,const dvariable& _r, 00069 const dvariable& _mu) 00070 { 00071 prevariable& x= (prevariable&)(_x); 00072 prevariable& r= (prevariable&)(_r); 00073 prevariable& mu= (prevariable&)(_mu); 00074 return exp(r*log(mu) + (r-1)*log(x)-mu*x-gammln(r)); 00075 }
Generated on Tue Mar 8 2016 19:51:35 for ADMB Documentation by 1.8.0 |