All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
beta_binomial_rng.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_SCAL_PROB_BETA_BINOMIAL_RNG_HPP
#define STAN_MATH_PRIM_SCAL_PROB_BETA_BINOMIAL_RNG_HPP
#include <stan/math/prim/scal/meta/OperandsAndPartials.hpp>
#include <stan/math/prim/scal/err/check_consistent_sizes.hpp>
#include <stan/math/prim/scal/err/check_nonnegative.hpp>
#include <stan/math/prim/scal/err/check_positive_finite.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/binomial_coefficient_log.hpp>
#include <stan/math/prim/scal/fun/digamma.hpp>
#include <stan/math/prim/scal/fun/lbeta.hpp>
#include <stan/math/prim/scal/fun/lgamma.hpp>
#include <stan/math/prim/scal/fun/value_of.hpp>
#include <stan/math/prim/scal/meta/include_summand.hpp>
#include <stan/math/prim/scal/prob/binomial_rng.hpp>
#include <stan/math/prim/scal/prob/beta_rng.hpp>
#include <stan/math/prim/scal/fun/F32.hpp>
#include <stan/math/prim/scal/fun/grad_F32.hpp>
namespace stan {
namespace math {
template <class RNG>
inline int
beta_binomial_rng(const int N,
const double alpha,
const double beta,
RNG& rng) {
static const char* function("stan::math::beta_binomial_rng");
using stan::math::check_positive_finite;
using stan::math::check_nonnegative;
check_nonnegative(function, "Population size parameter", N);
check_positive_finite(function,
"First prior sample size parameter", alpha);
check_positive_finite(function,
"Second prior sample size parameter", beta);
double a = stan::math::beta_rng(alpha, beta, rng);
while (a > 1 || a < 0)
a = stan::math::beta_rng(alpha, beta, rng);
return stan::math::binomial_rng(N, a, rng);
}
}
}
#endif
lgamma.hpp
stan::math::beta_rng
double beta_rng(const double alpha, const double beta, RNG &rng)
Definition: beta_rng.hpp:30
check_positive_finite.hpp
digamma.hpp
stan::math::beta_binomial_rng
int beta_binomial_rng(const int N, const double alpha, const double beta, RNG &rng)
Definition: beta_binomial_rng.hpp:26
binomial_coefficient_log.hpp
F32.hpp
include_summand.hpp
check_nonnegative.hpp
beta_rng.hpp
OperandsAndPartials.hpp
grad_F32.hpp
constants.hpp
lbeta.hpp
stan::math::check_nonnegative
bool check_nonnegative(const char *function, const char *name, const T_y &y)
Return true if y is non-negative.
Definition: check_nonnegative.hpp:66
value_of.hpp
check_consistent_sizes.hpp
stan::math::binomial_rng
int binomial_rng(const int N, const double theta, RNG &rng)
Definition: binomial_rng.hpp:31
stan::math::check_positive_finite
bool check_positive_finite(const char *function, const char *name, const T_y &y)
Return true if y is positive and finite.
Definition: check_positive_finite.hpp:28
binomial_rng.hpp

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