| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
binomial_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_BINOMIAL_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_BINOMIAL_RNG_HPP
3
4 #include <boost/random/binomial_distribution.hpp>
5 #include <boost/random/variate_generator.hpp>
6 #include <stan/math/prim/scal/meta/OperandsAndPartials.hpp>
7 #include <stan/math/prim/scal/err/check_consistent_sizes.hpp>
8 #include <stan/math/prim/scal/err/check_bounded.hpp>
9 #include <stan/math/prim/scal/err/check_finite.hpp>
10 #include <stan/math/prim/scal/err/check_greater_or_equal.hpp>
11 #include <stan/math/prim/scal/err/check_less_or_equal.hpp>
12 #include <stan/math/prim/scal/err/check_nonnegative.hpp>
13 #include <stan/math/prim/scal/fun/constants.hpp>
14 #include <stan/math/prim/scal/fun/inv_logit.hpp>
15 #include <stan/math/prim/scal/fun/log1m.hpp>
16 #include <stan/math/prim/scal/fun/log_inv_logit.hpp>
17 #include <stan/math/prim/scal/fun/multiply_log.hpp>
18 #include <stan/math/prim/scal/fun/value_of.hpp>
19 #include <stan/math/prim/scal/fun/binomial_coefficient_log.hpp>
20 #include <stan/math/prim/scal/fun/lbeta.hpp>
21 #include <stan/math/prim/scal/meta/include_summand.hpp>
22 #include <stan/math/prim/scal/fun/inc_beta.hpp>
23
24
25 namespace stan {
26
27 namespace math {
28
29 template <class RNG>
30 inline int
31 binomial_rng(const int N,
32 const double theta,
33 RNG& rng) {
34 using boost::variate_generator;
35 using boost::binomial_distribution;
36
37 static const char* function("stan::math::binomial_rng");
38
39 using stan::math::check_finite;
40 using stan::math::check_less_or_equal;
41 using stan::math::check_greater_or_equal;
42 using stan::math::check_nonnegative;
43
44 check_nonnegative(function, "Population size parameter", N);
45 check_finite(function, "Probability parameter", theta);
46 check_less_or_equal(function, "Probability parameter", theta, 1.0);
47 check_greater_or_equal(function, "Probability parameter", theta, 0.0);
48
49 variate_generator<RNG&, binomial_distribution<> >
50 binomial_rng(rng, binomial_distribution<>(N, theta));
51 return binomial_rng();
52 }
53
54 }
55 }
56 #endif
stan::math::check_greater_or_equal
bool check_greater_or_equal(const char *function, const char *name, const T_y &y, const T_low &low)
Return true if y is greater or equal than low.
Definition: check_greater_or_equal.hpp:84
binomial_coefficient_log.hpp
include_summand.hpp
multiply_log.hpp
check_nonnegative.hpp
log_inv_logit.hpp
check_less_or_equal.hpp
OperandsAndPartials.hpp
log1m.hpp
stan::math::check_less_or_equal
bool check_less_or_equal(const char *function, const char *name, const T_y &y, const T_high &high)
Return true if y is less or equal to high.
Definition: check_less_or_equal.hpp:81
check_bounded.hpp
stan::math::check_finite
bool check_finite(const char *function, const char *name, const T_y &y)
Return true if y is finite.
Definition: check_finite.hpp:62
constants.hpp
check_finite.hpp
lbeta.hpp
inc_beta.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
check_greater_or_equal.hpp
value_of.hpp
inv_logit.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 Home Page ] © 2011–2015, Stan Development Team.