ADMB Documentation  11.1.1916
 All Classes Files Functions Variables Typedefs Friends Defines
df1b2-separable/vgamdens.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: vgamdens.cpp 1709 2014-02-28 21:48:21Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #define HOME_VERSION
00012 #include <df1b2fun.h>
00013 
00018   df1b2variable gamma_density(const df1b2variable& _x,double r, double mu)
00019   {
00020     df1b2variable& x= (df1b2variable&)(_x);
00021 
00022     return exp(r*log(mu) + (r-1)*log(x)-mu*x-gammln(r));
00023   }
00024 
00029   df1b2variable gamma_density(const df1b2variable& _x,const df1b2variable& _r,
00030     const  df1b2variable& _mu)
00031   {
00032     df1b2variable& x= (df1b2variable&)(_x);
00033     df1b2variable& r= (df1b2variable&)(_r);
00034     df1b2variable& mu= (df1b2variable&)(_mu);
00035     return exp(r*log(mu) + (r-1)*log(x)-mu*x-gammln(r));
00036   }
00037 
00042   df1b2variable log_gamma_density(const df1b2variable& _x,double r, double mu)
00043   {
00044     df1b2variable& x= (df1b2variable&)(_x);
00045 
00046     return r*log(mu) + (r-1)*log(x)-mu*x-gammln(r);
00047   }
00048 
00053 df1b2variable log_gamma_density(const df1b2variable& _x,
00054   const df1b2variable& _r, const  df1b2variable& _mu)
00055   {
00056     df1b2variable& x= (df1b2variable&)(_x);
00057     df1b2variable& r= (df1b2variable&)(_r);
00058     df1b2variable& mu= (df1b2variable&)(_mu);
00059     return r*log(mu) + (r-1)*log(x)-mu*x-gammln(r);
00060   }