Stan Math Library: stan/math/prim/scal/prob/poisson_rng.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

poisson_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_POISSON_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_POISSON_RNG_HPP
3
4 #include <stan/math/prim/scal/err/check_consistent_sizes.hpp>
5 #include <stan/math/prim/scal/err/check_less.hpp>
6 #include <stan/math/prim/scal/err/check_nonnegative.hpp>
7 #include <stan/math/prim/scal/err/check_not_nan.hpp>
8 #include <stan/math/prim/scal/fun/constants.hpp>
9 #include <stan/math/prim/scal/fun/multiply_log.hpp>
10 #include <stan/math/prim/scal/fun/gamma_q.hpp>
11 #include <stan/math/prim/scal/fun/value_of.hpp>
12 #include <boost/math/special_functions/fpclassify.hpp>
13 #include <boost/random/poisson_distribution.hpp>
14 #include <boost/random/variate_generator.hpp>
15 #include <cmath>
16 #include <limits>
17
18 namespace stan {
19
20 namespace math {
21
22 template <class RNG>
23 inline int
24 poisson_rng(const double lambda,
25 RNG& rng) {
26 using boost::variate_generator;
27 using boost::random::poisson_distribution;
28
29 static const char* function("stan::math::poisson_rng");
30
31 check_not_nan(function, "Rate parameter", lambda);
32 check_nonnegative(function, "Rate parameter", lambda);
33 check_less(function, "Rate parameter", lambda, POISSON_MAX_RATE);
34
35 variate_generator<RNG&, poisson_distribution<> >
36 poisson_rng(rng, poisson_distribution<>(lambda));
37 return poisson_rng();
38 }
39 }
40 }
41 #endif
check_not_nan.hpp
stan::math::check_less
bool check_less(const char *function, const char *name, const T_y &y, const T_high &high)
Return true if y is strictly less than high.
Definition: check_less.hpp:81
stan::math::check_not_nan
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
Definition: check_not_nan.hpp:63
stan
Definition: log_sum_exp.hpp:8
gamma_q.hpp
multiply_log.hpp
check_nonnegative.hpp
stan::math::POISSON_MAX_RATE
const double POISSON_MAX_RATE
Largest rate parameter allowed in Poisson RNG.
Definition: constants.hpp:72
constants.hpp
stan::math::poisson_rng
int poisson_rng(const double lambda, RNG &rng)
Definition: poisson_rng.hpp:24
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_less.hpp
check_consistent_sizes.hpp

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