1 #ifndef STAN_MATH_PRIM_SCAL_PROB_BINOMIAL_RNG_HPP 2 #define STAN_MATH_PRIM_SCAL_PROB_BINOMIAL_RNG_HPP 8 #include <boost/random/binomial_distribution.hpp> 9 #include <boost/random/variate_generator.hpp> 31 template <
typename T_N,
typename T_theta,
class RNG>
33 const T_N& N,
const T_theta& theta, RNG& rng) {
34 using boost::binomial_distribution;
35 using boost::variate_generator;
37 static const char*
function =
"binomial_rng";
40 check_bounded(
function,
"Probability parameter", theta, 0.0, 1.0);
42 "Probability Parameter", theta);
49 for (
size_t m = 0; m < M; ++m) {
50 variate_generator<RNG&, binomial_distribution<> >
binomial_rng(
51 rng, binomial_distribution<>(N_vec[m], theta_vec[m]));
void check_bounded(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
Check if the value is between the low and high values, inclusively.
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
size_t max_size(const T1 &x1, const T2 &x2)
VectorBuilder< true, int, T_N, T_theta >::type binomial_rng(const T_N &N, const T_theta &theta, RNG &rng)
Return a pseudorandom binomial random variable for the given population size and chance of success pa...
VectorBuilder allocates type T1 values to be used as intermediate values.
void check_consistent_sizes(const char *function, const char *name1, const T1 &x1, const char *name2, const T2 &x2)
Check if the dimension of x1 is consistent with x2.