Stan Math Library
2.14.0
reverse mode automatic differentiation
stan
math
fwd
scal
fun
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:16
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:15
stan::math::grad_reg_inc_beta
void grad_reg_inc_beta(T &g1, T &g2, const T &a, const T &b, const T &z, const T &digammaA, const T &digammaB, const T &digammaSum, const T &betaAB)
Computes the gradients of the regularized incomplete beta function.
Definition:
grad_reg_inc_beta.hpp:32
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
lbeta.hpp
stan::math::fvar
Definition:
fvar.hpp:14
stan::math::digamma
fvar< T > digamma(const fvar< T > &x)
Return the derivative of the log gamma function at the specified argument.
Definition:
digamma.hpp:22
[
Stan Home Page
]
© 2011–2016, Stan Development Team.