ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
linad99/vgamdens.cpp
Go to the documentation of this file.
1 
8 #include <fvar.hpp>
9 
18  dvariable log_gamma_density(const prevariable& _x,double r, double mu)
19  {
20  prevariable& x= (prevariable&)(_x);
21 
22  return r*log(mu) + (r-1)*log(x)-mu*x-gammln(r);
23  }
24 
34  const dvariable& _mu)
35  {
36  prevariable& x= (prevariable&)(_x);
37  prevariable& r= (prevariable&)(_r);
38  prevariable& mu= (prevariable&)(_mu);
39  return r*log(mu) + (r-1)*log(x)-mu*x-gammln(r);
40  }
41 
51  dvariable gamma_density(const prevariable& _x,double r, double mu)
52  {
53  prevariable& x= (prevariable&)(_x);
54 
55  return exp(r*log(mu) + (r-1)*log(x)-mu*x-gammln(r));
56  }
66  const dvariable& _mu)
67  {
68  prevariable& x= (prevariable&)(_x);
69  prevariable& r= (prevariable&)(_r);
70  prevariable& mu= (prevariable&)(_mu);
71  return exp(r*log(mu) + (r-1)*log(x)-mu*x-gammln(r));
72  }
Base class for dvariable.
Definition: fvar.hpp:1315
double gammln(double xx)
Log gamma function.
Definition: combc.cpp:52
#define x
double gamma_density(double x, double r, double mu)
Gamma probability density function; constant objects.
Definition: cgamdens.cpp:21
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
Definition: d3arr2a.cpp:28
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13
double log_gamma_density(double x, double r, double mu)
Log gamma probability density function; constant objects.
Definition: cgamdens.cpp:35