ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
df1b2-separable/vgamdens.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00007 #include <df1b2fun.h>
00008 
00013   df1b2variable gamma_density(const df1b2variable& _x,double r, double mu)
00014   {
00015     df1b2variable& x= (df1b2variable&)(_x);
00016 
00017     return exp(r*log(mu) + (r-1)*log(x)-mu*x-gammln(r));
00018   }
00019 
00024   df1b2variable gamma_density(const df1b2variable& _x,const df1b2variable& _r,
00025     const  df1b2variable& _mu)
00026   {
00027     df1b2variable& x= (df1b2variable&)(_x);
00028     df1b2variable& r= (df1b2variable&)(_r);
00029     df1b2variable& mu= (df1b2variable&)(_mu);
00030     return exp(r*log(mu) + (r-1)*log(x)-mu*x-gammln(r));
00031   }
00032 
00037   df1b2variable log_gamma_density(const df1b2variable& _x,double r, double mu)
00038   {
00039     df1b2variable& x= (df1b2variable&)(_x);
00040 
00041     return r*log(mu) + (r-1)*log(x)-mu*x-gammln(r);
00042   }
00043 
00048 df1b2variable log_gamma_density(const df1b2variable& _x,
00049   const df1b2variable& _r, const  df1b2variable& _mu)
00050   {
00051     df1b2variable& x= (df1b2variable&)(_x);
00052     df1b2variable& r= (df1b2variable&)(_r);
00053     df1b2variable& mu= (df1b2variable&)(_mu);
00054     return r*log(mu) + (r-1)*log(x)-mu*x-gammln(r);
00055   }