32 #ifndef VSMC_RNG_STUDENT_T_DISTRIBUTION_HPP 33 #define VSMC_RNG_STUDENT_T_DISTRIBUTION_HPP 45 template <
typename RealType>
55 template <
typename RealType>
65 return std::numeric_limits<result_type>::lowest();
77 template <
typename RNGType>
81 result_type u = std::numeric_limits<result_type>::infinity();
83 while (!std::isfinite(u))
84 u = n() / chi_squared_(rng);
87 while (!std::isfinite(u))
88 u = param.
n() / chi_squared(rng);
98 template <std::
size_t K,
typename RealType,
typename RNGType>
100 RNGType &rng, std::size_t n, RealType *r, RealType df)
104 mul(n, 1 / df, r, r);
107 rng, n, s.data(),
static_cast<RealType
>(0), static_cast<RealType>(1));
108 div(n, s.data(), r, r);
111 for (std::size_t i = 0; i != n; ++i)
112 if (!std::isfinite(r[i]))
125 #endif // VSMC_RNG_STUDENT_T_DISTRIBUTION_HPP
#define VSMC_DEFINE_RNG_DISTRIBUTION_IMPL_1(name, p1)
void mul(std::size_t n, const float *a, const float *b, float *y)
void sqrt(std::size_t n, const float *a, float *y)
#define VSMC_DEFINE_RNG_DISTRIBUTION_MEMBER_2(T1, m1, T2, m2)
void normal_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating Normal random variates.
void student_t_distribution_impl(RNGType &rng, std::size_t n, RealType *r, RealType df)
bool is_equal(const T &a, const T &b, std::true_type)
void div(std::size_t n, const float *a, const float *b, float *y)
void chi_squared_distribution(RNGType &rng, std::size_t n, RealType *r, RealType df)
Generating random variates.
std::array with proper alignment
bool student_t_distribution_check_param(RealType n)
#define VSMC_DEFINE_RNG_DISTRIBUTION_RAND_1(Name, name, p1)
#define VSMC_DEFINE_RNG_DISTRIBUTION_1(Name, name, p1, v1)