All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
grad_inc_beta.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_REV_SCAL_FUN_GRAD_INC_BETA_HPP
#define STAN_MATH_REV_SCAL_FUN_GRAD_INC_BETA_HPP
#include <stan/math/prim/scal/fun/grad_2F1.hpp>
#include <stan/math/rev/core.hpp>
#include <stan/math/rev/scal/fun/exp.hpp>
#include <stan/math/rev/scal/fun/fabs.hpp>
#include <stan/math/prim/scal/fun/lbeta.hpp>
#include <stan/math/rev/scal/fun/lgamma.hpp>
#include <stan/math/rev/scal/fun/log.hpp>
#include <stan/math/rev/scal/fun/log1m.hpp>
#include <stan/math/rev/scal/fun/value_of.hpp>
#include <stan/math/prim/scal/fun/value_of.hpp>
#include <stan/math/rev/scal/fun/inc_beta.hpp>
#include <cmath>
namespace stan {
namespace math {
// Gradient of the incomplete beta function beta(a, b, z)
// with respect to the first two arguments, using the
// equivalence to a hypergeometric function.
// See http://dlmf.nist.gov/8.17#ii
void grad_inc_beta(var& g1, var& g2,
const var& a, const var& b, const var& z) {
var c1 = log(z);
var c2 = log1m(z);
var c3 = exp(lbeta(a, b)) * inc_beta(a, b, z);
var C = exp(a * c1 + b * c2) / a;
var dF1 = 0;
var dF2 = 0;
if (value_of(value_of(C)))
grad_2F1(dF1, dF2, a + b, var(1.0), a + 1, z);
g1 = (c1 - 1.0 / a) * c3 + C * (dF1 + dF2);
g2 = c2 * c3 + C * dF1;
}
}
}
#endif
core.hpp
exp.hpp
stan::math::value_of
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Definition: value_of.hpp:16
stan::math::lbeta
fvar< T > lbeta(const fvar< T > &x1, const fvar< T > &x2)
Definition: lbeta.hpp:16
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
stan::math::inc_beta
fvar< T > inc_beta(const fvar< T > &a, const fvar< T > &b, const fvar< T > &x)
Definition: inc_beta.hpp:20
inc_beta.hpp
stan::math::grad_inc_beta
void grad_inc_beta(stan::math::fvar< T > &g1, stan::math::fvar< T > &g2, stan::math::fvar< T > a, stan::math::fvar< T > b, stan::math::fvar< T > z)
Definition: grad_inc_beta.hpp:24
stan::math::exp
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
log.hpp
lgamma.hpp
grad_2F1.hpp
log1m.hpp
fabs.hpp
lbeta.hpp
value_of.hpp
value_of.hpp
stan::math::log1m
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:16
stan::math::grad_2F1
void grad_2F1(T &gradA, T &gradC, T a, T b, T c, T z, T precision=1e-6)
Definition: grad_2F1.hpp:13

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