Stan Math Library  2.20.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 
7 
8 namespace stan {
9 namespace math {
10 
31 template <typename T_N, typename T_shape1, typename T_shape2, class RNG>
33 beta_binomial_rng(const T_N &N, const T_shape1 &alpha, const T_shape2 &beta,
34  RNG &rng) {
35  static const char *function = "beta_binomial_rng";
36 
37  check_nonnegative(function, "Population size parameter", N);
38  check_positive_finite(function, "First prior sample size parameter", alpha);
39  check_positive_finite(function, "Second prior sample size parameter", beta);
40  check_consistent_sizes(function, "First prior sample size parameter", alpha,
41  "Second prior sample size parameter", beta);
42 
43  auto p = beta_rng(alpha, beta, rng);
44  return binomial_rng(N, p, rng);
45 }
46 
47 } // namespace math
48 } // namespace stan
49 #endif
VectorBuilder< true, double, T_shape1, T_shape2 >::type beta_rng(const T_shape1 &alpha, const T_shape2 &beta, RNG &rng)
Return a Beta random variate with the supplied success and failure parameters using the given random ...
Definition: beta_rng.hpp:34
void check_nonnegative(const char *function, const char *name, const T_y &y)
Check if y is non-negative.
fvar< T > beta(const fvar< T > &x1, const fvar< T > &x2)
Return fvar with the beta function applied to the specified arguments and its gradient.
Definition: beta.hpp:51
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.
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< true, int, T_N, T_shape1, T_shape2 >::type beta_binomial_rng(const T_N &N, const T_shape1 &alpha, const T_shape2 &beta, RNG &rng)
Return a beta-binomial random variate with the specified population size, success, and failure parameters using the given random number generator.
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.

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