Stan Math Library  2.15.0
reverse mode automatic differentiation
beta_binomial_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_BETA_BINOMIAL_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_BETA_BINOMIAL_RNG_HPP
3 
16 
17 namespace stan {
18  namespace math {
19 
33  template <class RNG>
34  inline int
36  double alpha,
37  double beta,
38  RNG& rng) {
39  static const char* function("beta_binomial_rng");
40 
41  check_nonnegative(function, "Population size parameter", N);
42  check_positive_finite(function,
43  "First prior sample size parameter", alpha);
44  check_positive_finite(function,
45  "Second prior sample size parameter", beta);
46 
47  double p = beta_rng(alpha, beta, rng);
48  return binomial_rng(N, p, rng);
49  }
50 
51 
52  }
53 }
54 #endif
double beta_rng(double alpha, double beta, RNG &rng)
Return a pseudorandom Beta variate with the supplied success and failure parameters and specified ran...
Definition: beta_rng.hpp:41
int beta_binomial_rng(int N, double alpha, double beta, RNG &rng)
Return a pseudorandom Beta-Binomial draw with specified population size, prior success, and prior failure parameter using the specified random number generator.
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 binomial_rng(int N, double theta, RNG &rng)
Return a pseudorandom Binomial random variable for the given population size and chance of success pa...

     [ Stan Home Page ] © 2011–2016, Stan Development Team.