poisson_log_rng.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_SCAL_PROB_POISSON_LOG_RNG_HPP
#define STAN_MATH_PRIM_SCAL_PROB_POISSON_LOG_RNG_HPP
#include <stan/math/prim/scal/err/check_consistent_sizes.hpp>
#include <stan/math/prim/scal/err/check_less.hpp>
#include <stan/math/prim/scal/err/check_nonnegative.hpp>
#include <stan/math/prim/scal/err/check_not_nan.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/multiply_log.hpp>
#include <stan/math/prim/scal/fun/gamma_q.hpp>
#include <stan/math/prim/scal/fun/value_of.hpp>
#include <boost/random/poisson_distribution.hpp>
#include <boost/random/variate_generator.hpp>
#include <limits>
namespace stan {
namespace math {
template <class RNG>
inline int
poisson_log_rng(double alpha,
RNG& rng) {
using boost::variate_generator;
using boost::random::poisson_distribution;
static const char* function("poisson_log_rng");
static const double POISSON_MAX_LOG_RATE = 30 * std::log(2);
using std::exp;
check_not_nan(function, "Log rate parameter", alpha);
check_less(function, "Log rate parameter", alpha, POISSON_MAX_LOG_RATE);
variate_generator<RNG&, poisson_distribution<> >
poisson_rng(rng, poisson_distribution<>(exp(alpha)));
return poisson_rng();
}
}
}
#endif
check_not_nan.hpp
stan
Definition: log_sum_exp.hpp:8
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:14
stan::math::poisson_rng
int poisson_rng(double lambda, RNG &rng)
Definition: poisson_rng.hpp:22
stan::math::poisson_log_rng
int poisson_log_rng(double alpha, RNG &rng)
Definition: poisson_log_rng.hpp:21
gamma_q.hpp
multiply_log.hpp
check_nonnegative.hpp
stan::math::exp
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
stan::math::check_not_nan
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
Definition: check_not_nan.hpp:57
constants.hpp
value_of.hpp
check_less.hpp
check_consistent_sizes.hpp
stan::math::check_less
void check_less(const char *function, const char *name, const T_y &y, const T_high &high)
Check if y is strictly less than high.
Definition: check_less.hpp:78

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