1 #ifndef STAN_MATH_PRIM_SCAL_PROB_BERNOULLI_RNG_HPP 2 #define STAN_MATH_PRIM_SCAL_PROB_BERNOULLI_RNG_HPP 7 #include <boost/random/bernoulli_distribution.hpp> 8 #include <boost/random/variate_generator.hpp> 27 template <
typename T_theta,
class RNG>
29 const T_theta& theta, RNG& rng) {
30 using boost::bernoulli_distribution;
31 using boost::variate_generator;
33 static const char*
function =
"bernoulli_rng";
36 check_bounded(
function,
"Probability parameter", theta, 0.0, 1.0);
42 for (
size_t n = 0; n < N; ++n) {
43 variate_generator<RNG&, bernoulli_distribution<> >
bernoulli_rng(
44 rng, bernoulli_distribution<>(theta_vec[n]));
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
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.
VectorBuilder< true, int, T_theta >::type bernoulli_rng(const T_theta &theta, RNG &rng)
Return a Bernoulli random variate with specified chance of success parameter using the specified rand...
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
size_t length(const std::vector< T > &x)
Returns the length of the provided std::vector.
VectorBuilder allocates type T1 values to be used as intermediate values.