1 #ifndef STAN_MATH_REV_SCAL_FUN_IBETA_HPP 2 #define STAN_MATH_REV_SCAL_FUN_IBETA_HPP 18 double ibeta_hypergeometric_helper(
double a,
double b,
double z,
19 double precision = 1
e-8,
20 double max_steps = 1000) {
26 while (
std::abs(diff) > precision && ++k < max_steps) {
35 class ibeta_vvv_vari :
public op_vvv_vari {
37 ibeta_vvv_vari(vari* avi, vari* bvi, vari* xvi) :
38 op_vvv_vari(
ibeta(avi->val_, bvi->val_, xvi->val_),
42 double a = avi_->val_;
43 double b = bvi_->val_;
44 double c = cvi_->val_;
54 * ibeta_hypergeometric_helper(a, 1-b, c);
57 * ibeta_hypergeometric_helper(b, 1-a, 1-c)
61 boost::math::ibeta_derivative(a, b, c);
64 class ibeta_vvd_vari :
public op_vvd_vari {
66 ibeta_vvd_vari(vari* avi, vari* bvi,
double x) :
67 op_vvd_vari(
ibeta(avi->val_, bvi->val_, x), avi, bvi, x) {
70 double a = avi_->val_;
71 double b = bvi_->val_;
82 * ibeta_hypergeometric_helper(a, 1-b, c);
85 * ibeta_hypergeometric_helper(b, 1-a, 1-c)
90 class ibeta_vdv_vari :
public op_vdv_vari {
92 ibeta_vdv_vari(vari* avi,
double b, vari* xvi) :
93 op_vdv_vari(
ibeta(avi->val_, b, xvi->val_), avi, b, xvi) {
96 double a = avi_->val_;
98 double c = cvi_->val_;
111 * ibeta_hypergeometric_helper(a, 1-b, c);
113 boost::math::ibeta_derivative(a, b, c);
116 class ibeta_vdd_vari :
public op_vdd_vari {
118 ibeta_vdd_vari(vari* avi,
double b,
double x) :
119 op_vdd_vari(
ibeta(avi->val_, b, x), avi, b, x) {
122 double a = avi_->val_;
137 * ibeta_hypergeometric_helper(a, 1-b, c);
140 class ibeta_dvv_vari :
public op_dvv_vari {
142 ibeta_dvv_vari(
double a, vari* bvi, vari* xvi) :
143 op_dvv_vari(
ibeta(a, bvi->val_, xvi->val_), a, bvi, xvi) {
147 double b = bvi_->val_;
148 double c = cvi_->val_;
159 * ibeta_hypergeometric_helper(b, 1-a, 1-c)
163 boost::math::ibeta_derivative(a, b, c);
166 class ibeta_dvd_vari :
public op_dvd_vari {
168 ibeta_dvd_vari(
double a, vari* bvi,
double x) :
169 op_dvd_vari(
ibeta(a, bvi->val_, x), a, bvi, x) {
173 double b = bvi_->val_;
185 * ibeta_hypergeometric_helper(b, 1-a, 1-c)
190 class ibeta_ddv_vari :
public op_ddv_vari {
192 ibeta_ddv_vari(
double a,
double b, vari* xvi) :
193 op_ddv_vari(
ibeta(a, b, xvi->val_), a, b, xvi) {
198 double c = cvi_->val_;
201 boost::math::ibeta_derivative(a, b, c);
fvar< T > abs(const fvar< T > &x)
fvar< T > log(const fvar< T > &x)
Independent (input) and dependent (output) variables for gradients.
fvar< T > sin(const fvar< T > &x)
vari * vi_
Pointer to the implementation of this variable.
double ibeta(double a, double b, double x)
The normalized incomplete beta function of a, b, and x.
double e()
Return the base of the natural logarithm.
var ibeta(const var &a, const var &b, const var &x)
The normalized incomplete beta function of a, b, and x.
double pi()
Return the value of pi.
double adj_
The adjoint of this variable, which is the partial derivative of this variable with respect to the ro...
fvar< T > pow(const fvar< T > &x1, const fvar< T > &x2)
fvar< T > tgamma(const fvar< T > &x)
Return the result of applying the gamma function to the specified argument.
fvar< T > digamma(const fvar< T > &x)
Return the derivative of the log gamma function at the specified argument.