| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

inc_beta.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_SCAL_FUN_INC_BETA_HPP
2 #define STAN_MATH_FWD_SCAL_FUN_INC_BETA_HPP
3
4 #include <boost/math/special_functions/beta.hpp>
5 #include <stan/math/prim/scal/fun/grad_reg_inc_beta.hpp>
6 #include <stan/math/fwd/scal/fun/grad_inc_beta.hpp>
7 #include <stan/math/fwd/scal/fun/pow.hpp>
8 #include <stan/math/fwd/scal/fun/exp.hpp>
9 #include <stan/math/fwd/scal/fun/lbeta.hpp>
10 #include <stan/math/fwd/scal/fun/digamma.hpp>
11 #include <stan/math/fwd/core.hpp>
12 #include <stan/math/prim/scal/fun/lbeta.hpp>
13 #include <stan/math/prim/scal/fun/digamma.hpp>
14
15 namespace stan {
16
17 namespace math {
18
19 template<typename T>
20 inline fvar<T> inc_beta(const fvar<T>& a,
21 const fvar<T>& b,
22 const fvar<T>& x) {
23 using stan::math::digamma;
24 using stan::math::grad_reg_inc_beta;
25 using stan::math::inc_beta;
26 using stan::math::lbeta;
27 using stan::math::digamma;
28 using stan::math::lbeta;
29 using stan::math::pow;
30 using std::exp;
31 using std::pow;
32
33 T d_a; T d_b; T d_x;
34
35 grad_reg_inc_beta(d_a, d_b, a.val_, b.val_, x.val_,
36 digamma(a.val_), digamma(b.val_),
37 digamma(a.val_+b.val_),
38 exp(lbeta(a.val_, b.val_)));
39 d_x = pow((1-x.val_), b.val_-1)*pow(x.val_, a.val_-1)
40 / exp(lbeta(a.val_, b.val_));
41 return fvar<T>(inc_beta(a.val_, b.val_, x.val_),
42 a.d_ * d_a + b.d_ * d_b + x.d_ * d_x);
43 }
44 }
45 }
46
47 #endif
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:15
stan
Definition: log_sum_exp.hpp:8
stan::math::lbeta
fvar< T > lbeta(const fvar< T > &x1, const fvar< T > &x2)
Definition: lbeta.hpp:16
digamma.hpp
pow.hpp
grad_inc_beta.hpp
digamma.hpp
stan::math::inc_beta
fvar< T > inc_beta(const fvar< T > &a, const fvar< T > &b, const fvar< T > &x)
Definition: inc_beta.hpp:20
stan::math::fvar::val_
T val_
Definition: fvar.hpp:14
stan::math::exp
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
grad_reg_inc_beta.hpp
lbeta.hpp
stan::math::pow
fvar< T > pow(const fvar< T > &x1, const fvar< T > &x2)
Definition: pow.hpp:18
exp.hpp
stan::math::grad_reg_inc_beta
void grad_reg_inc_beta(T &g1, T &g2, T a, T b, T z, T digammaA, T digammaB, T digammaSum, T betaAB)
Definition: grad_reg_inc_beta.hpp:14
lbeta.hpp
stan::math::fvar
Definition: fvar.hpp:13
stan::math::digamma
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:16

[ Stan Home Page ] © 2011–2016, Stan Development Team.