Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ grad_reg_inc_gamma()

template<typename T1 , typename T2 >
return_type_t< T1, T2 > stan::math::grad_reg_inc_gamma ( T1  a,
T2  z,
T1  g,
T1  dig,
double  precision = 1e-6,
int  max_steps = 1e5 
)

Gradient of the regularized incomplete gamma functions igamma(a, z)

For small z, the gradient is computed via the series expansion; for large z, the series is numerically inaccurate due to cancellation and the asymptotic expansion is used.

Template Parameters
T1type of the shape parameter
T2type of the location parameter
Parameters
ashape parameter, a > 0
zlocation z >= 0
gstan::math::tgamma(a) (precomputed value)
digboost::math::digamma(a) (precomputed value)
precisionrequired precision; applies to series expansion only
max_stepsnumber of steps to take.
Exceptions
throwsstd::domain_error if not converged after max_steps or increment overflows to inf.

For the asymptotic expansion, the gradient is given by:

\[ \begin{array}{rcl} \Gamma(a, z) & = & z^{a-1}e^{-z} \sum_{k=0}^N \frac{(a-1)_k}{z^k} \qquad , z \gg a\\ Q(a, z) & = & \frac{z^{a-1}e^{-z}}{\Gamma(a)} \sum_{k=0}^N \frac{(a-1)_k}{z^k}\\ (a)_k & = & (a)_{k-1}(a-k)\\ \frac{d}{da} (a)_k & = & (a)_{k-1} + (a-k)\frac{d}{da} (a)_{k-1}\\ \frac{d}{da}Q(a, z) & = & (log(z) - \psi(a)) Q(a, z)\\ && + \frac{z^{a-1}e^{-z}}{\Gamma(a)} \sum_{k=0}^N \left(\frac{d}{da} (a-1)_k\right) \frac{1}{z^k} \end{array} \]

Definition at line 52 of file grad_reg_inc_gamma.hpp.