Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
poisson_log_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_POISSON_LOG_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_POISSON_LOG_RNG_HPP
3 
13 #include <boost/math/special_functions/fpclassify.hpp>
14 #include <boost/random/poisson_distribution.hpp>
15 #include <boost/random/variate_generator.hpp>
16 #include <limits>
17 
18 namespace stan {
19 
20  namespace math {
21 
22  template <class RNG>
23  inline int
24  poisson_log_rng(const double alpha,
25  RNG& rng) {
26  using boost::variate_generator;
27  using boost::random::poisson_distribution;
28 
29  static const char* function("stan::math::poisson_log_rng");
30  static const double POISSON_MAX_LOG_RATE = 30 * std::log(2);
31 
35  using std::exp;
36 
37  check_not_nan(function, "Log rate parameter", alpha);
38  check_less(function, "Log rate parameter", alpha, POISSON_MAX_LOG_RATE);
39 
40  variate_generator<RNG&, poisson_distribution<> >
41  poisson_rng(rng, poisson_distribution<>(exp(alpha)));
42  return poisson_rng();
43  }
44  }
45 }
46 #endif
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
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
int poisson_log_rng(const double alpha, RNG &rng)
int poisson_rng(const double lambda, RNG &rng)
Definition: poisson_rng.hpp:25
bool check_nonnegative(const char *function, const char *name, const T_y &y)
Return true if y is non-negative.

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