| Stan Math Library 2.12.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 namespace math {
17
18 template<typename T>
19 inline fvar<T> inc_beta(const fvar<T>& a,
20 const fvar<T>& b,
21 const fvar<T>& x) {
22 using std::exp;
23 using std::pow;
24
25 T d_a; T d_b; T d_x;
26
27 grad_reg_inc_beta(d_a, d_b, a.val_, b.val_, x.val_,
28 digamma(a.val_), digamma(b.val_),
29 digamma(a.val_+b.val_),
30 exp(lbeta(a.val_, b.val_)));
31 d_x = pow((1-x.val_), b.val_-1)*pow(x.val_, a.val_-1)
32 / exp(lbeta(a.val_, b.val_));
33 return fvar<T>(inc_beta(a.val_, b.val_, x.val_),
34 a.d_ * d_a + b.d_ * d_b + x.d_ * d_x);
35 }
36 }
37 }
38
39 #endif
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:14
stan
Definition: log_sum_exp.hpp:8
stan::math::lbeta
fvar< T > lbeta(const fvar< T > &x1, const fvar< T > &x2)
Definition: lbeta.hpp:15
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:19
stan::math::fvar::val_
T val_
Definition: fvar.hpp:13
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:17
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:12
stan::math::digamma
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:15

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