1#ifndef STAN_MATH_PRIM_PROB_POISSON_LOG_RNG_HPP
2#define STAN_MATH_PRIM_PROB_POISSON_LOG_RNG_HPP
10#include <boost/random/poisson_distribution.hpp>
11#include <boost/random/variate_generator.hpp>
30template <
typename T_rate,
class RNG>
32 const T_rate& alpha, RNG& rng) {
33 using boost::variate_generator;
34 using boost::random::poisson_distribution;
35 static constexpr const char* function =
"poisson_log_rng";
36 static constexpr double POISSON_MAX_LOG_RATE = 30 *
LOG_TWO;
37 const auto& alpha_ref =
to_ref(alpha);
39 check_less(function,
"Log rate parameter", alpha_ref, POISSON_MAX_LOG_RATE);
45 for (
size_t n = 0; n < N; ++n) {
46 variate_generator<RNG&, poisson_distribution<> >
poisson_rng(
47 rng, poisson_distribution<>(std::exp(alpha_vec[n])));
typename helper::type type
VectorBuilder allocates type T1 values to be used as intermediate values.
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
VectorBuilder< true, int, T_rate >::type poisson_rng(const T_rate &lambda, RNG &rng)
Return a Poisson random variate with specified rate parameter using the given random number generator...
VectorBuilder< true, int, T_rate >::type poisson_log_rng(const T_rate &alpha, RNG &rng)
Return a Poisson random variate with specified log rate parameter using the given random number gener...
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
static constexpr double LOG_TWO
The natural logarithm of 2, .
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
void check_finite(const char *function, const char *name, const T_y &y)
Return true if all values in y are finite.
void check_less(const char *function, const char *name, const T_y &y, const T_high &high, Idxs... idxs)
Throw an exception if y is not strictly less than high.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...