1#ifndef STAN_MATH_PRIM_PROB_RAYLEIGH_RNG_HPP
2#define STAN_MATH_PRIM_PROB_RAYLEIGH_RNG_HPP
9#include <boost/random/uniform_real_distribution.hpp>
10#include <boost/random/variate_generator.hpp>
29template <
typename T_scale,
class RNG>
31 const T_scale& sigma, RNG& rng) {
32 using boost::variate_generator;
33 using boost::random::uniform_real_distribution;
34 static constexpr const char* function =
"rayleigh_rng";
35 const auto& sigma_ref =
to_ref(sigma);
42 variate_generator<RNG&, uniform_real_distribution<> >
uniform_rng(
43 rng, uniform_real_distribution<>(0.0, 1.0));
44 for (
size_t n = 0; n < N; ++n) {
45 output[n] = sigma_vec[n] * std::sqrt(-2.0 * std::log(
uniform_rng()));
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, double, T_scale >::type rayleigh_rng(const T_scale &sigma, RNG &rng)
Return a Rayleigh random variate with scale parameter sigma using the specified random number generat...
VectorBuilder< true, double, T_alpha, T_beta >::type uniform_rng(const T_alpha &alpha, const T_beta &beta, RNG &rng)
Return a uniform random variate for the given upper and lower bounds using the specified random numbe...
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...