1 #ifndef STAN_MATH_PRIM_SCAL_PROB_NEG_BINOMIAL_2_LOG_RNG_HPP 2 #define STAN_MATH_PRIM_SCAL_PROB_NEG_BINOMIAL_2_LOG_RNG_HPP 4 #include <boost/math/special_functions/digamma.hpp> 5 #include <boost/random/negative_binomial_distribution.hpp> 6 #include <boost/random/variate_generator.hpp> 30 using boost::variate_generator;
31 using boost::random::negative_binomial_distribution;
32 using boost::random::poisson_distribution;
33 using boost::gamma_distribution;
35 static const char*
function(
"neg_binomial_2_log_rng");
40 double exp_eta_div_phi =
std::exp(eta)/phi;
44 "Exponential of the log-location parameter " 45 "divided by the precision parameter",
48 double rng_from_gamma =
49 variate_generator<RNG&, gamma_distribution<> >
50 (rng, gamma_distribution<>(phi, exp_eta_div_phi))();
54 "Random number that came from gamma distribution",
57 "Random number that came from gamma distribution",
60 "Random number that came from gamma distribution",
63 return variate_generator<RNG&, poisson_distribution<> >
64 (rng, poisson_distribution<>(rng_from_gamma))();
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.
int neg_binomial_2_log_rng(double eta, double phi, RNG &rng)
fvar< T > exp(const fvar< T > &x)
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
const double POISSON_MAX_RATE
Largest rate parameter allowed in Poisson RNG.
void check_less(const char *function, const char *name, const T_y &y, const T_high &high)
Check if y is strictly less than high.