1 #ifndef __STAN__PROB__DISTRIBUTIONS__UNIVARIATE__DISCRETE__NEG_BINOMIAL_HPP__
2 #define __STAN__PROB__DISTRIBUTIONS__UNIVARIATE__DISCRETE__NEG_BINOMIAL_HPP__
14 template <
bool propto,
15 typename T_shape,
typename T_inv_scale,
17 typename boost::math::tools::promote_args<T_shape, T_inv_scale>::type
20 const T_inv_scale& beta,
23 static const char*
function =
"stan::prob::neg_binomial_log(%1%)";
28 using boost::math::tools::promote_args;
30 typename promote_args<T_shape, T_inv_scale>::type lp;
33 if (!
check_finite(
function, alpha,
"Shape parameter", &lp, Policy()))
35 if (!
check_positive(
function, alpha,
"Shape parameter", &lp, Policy()))
37 if (!
check_finite(
function, beta,
"Inverse scale parameter",
55 typename promote_args<T_shape, T_inv_scale>::type lambda;
56 lambda = alpha / beta;
64 lp += binomial_coefficient_log<T_shape>(n + alpha - 1.0, n);
66 lp += -n *
log1p(beta) + alpha *
log(beta / (1 + beta));
70 template <
bool propto,
71 typename T_shape,
typename T_inv_scale>
73 typename boost::math::tools::promote_args<T_shape, T_inv_scale>::type
76 const T_inv_scale& beta) {
77 return neg_binomial_log<propto>(n,alpha,beta,
81 template <
typename T_shape,
typename T_inv_scale,
84 typename boost::math::tools::promote_args<T_shape, T_inv_scale>::type
87 const T_inv_scale& beta,
89 return neg_binomial_log<false>(n,alpha,beta,Policy());
92 template <
typename T_shape,
typename T_inv_scale>
94 typename boost::math::tools::promote_args<T_shape, T_inv_scale>::type
97 const T_inv_scale& beta) {
98 return neg_binomial_log<false>(n,alpha,beta,