| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

grad_reg_inc_beta.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_GRAD_REG_INC_BETA_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_GRAD_REG_INC_BETA_HPP
3
4 #include <stan/math/prim/scal/fun/grad_inc_beta.hpp>
5 #include <stan/math/prim/scal/fun/inc_beta.hpp>
6 #include <stan/math/prim/scal/fun/lbeta.hpp>
7 #include <cmath>
8
9 namespace stan {
10 namespace math {
11
12 // Gradient of the regularized incomplete beta function ibeta(a, b, z)
13 template<typename T>
14 void grad_reg_inc_beta(T& g1, T& g2, T a, T b, T z,
15 T digammaA, T digammaB, T digammaSum, T betaAB) {
16 using std::exp;
17
18 T dBda = 0;
19 T dBdb = 0;
20 grad_inc_beta(dBda, dBdb, a, b, z);
21 T b1 = exp(lbeta(a, b)) * inc_beta(a, b, z);
22 g1 = (dBda - b1 * (digammaA - digammaSum)) / betaAB;
23 g2 = (dBdb - b1 * (digammaB - digammaSum)) / betaAB;
24 }
25
26 }
27 }
28 #endif
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
stan::math::grad_inc_beta
void grad_inc_beta(fvar< T > &g1, fvar< T > &g2, fvar< T > a, fvar< T > b, fvar< T > z)
Gradient of the incomplete beta function beta(a, b, z) with respect to the first two arguments...
Definition: grad_inc_beta.hpp:34
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::exp
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
grad_inc_beta.hpp
lbeta.hpp
inc_beta.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

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