Automatic Differentiation
 
Loading...
Searching...
No Matches
grad_reg_inc_beta.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_GRAD_REG_INC_BETA_HPP
2#define STAN_MATH_PRIM_FUN_GRAD_REG_INC_BETA_HPP
3
8#include <cmath>
9
10namespace stan {
11namespace math {
12
32template <typename T>
33void grad_reg_inc_beta(T& g1, T& g2, const T& a, const T& b, const T& z,
34 const T& digammaA, const T& digammaB,
35 const T& digammaSum, const T& betaAB) {
36 using std::exp;
37 T dBda = 0;
38 T dBdb = 0;
39 grad_inc_beta(dBda, dBdb, a, b, z);
40 T b1 = beta(a, b) * inc_beta(a, b, z);
41 g1 = (dBda - b1 * (digammaA - digammaSum)) / betaAB;
42 g2 = (dBdb - b1 * (digammaB - digammaSum)) / betaAB;
43}
44
45} // namespace math
46} // namespace stan
47#endif
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.
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.
fvar< T > inc_beta(const fvar< T > &a, const fvar< T > &b, const fvar< T > &x)
Definition inc_beta.hpp:19
fvar< T > beta(const fvar< T > &x1, const fvar< T > &x2)
Return fvar with the beta function applied to the specified arguments and its gradient.
Definition beta.hpp:51
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9