32 #ifndef VSMC_RNG_LOGISTIC_DISTRIBUTION_HPP 33 #define VSMC_RNG_LOGISTIC_DISTRIBUTION_HPP 44 template <
typename RealType>
54 template <
typename RealType>
62 return std::numeric_limits<result_type>::lowest();
70 template <
typename RNGType>
76 return param.
a() + param.
b() *
std::log(u / (1 - u));
83 template <std::
size_t K,
typename RealType,
typename RNGType>
85 RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
89 sub(n, static_cast<RealType>(1), r, s);
99 template <
typename RealType,
typename RNGType>
101 RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
103 static_assert(std::is_floating_point<RealType>::value,
104 "**logistic_distribution** USED WITH RealType OTHER THAN FLOATING " 107 const std::size_t k = 1024;
108 const std::size_t m = n / k;
109 const std::size_t l = n % k;
110 for (std::size_t i = 0; i != m; ++i, r += k)
111 internal::logistic_distribution_impl<k>(rng, k, r, a, b);
112 internal::logistic_distribution_impl<k>(rng, l, r, a, b);
119 #endif // VSMC_RNG_LOGISTIC_DISTRIBUTION_HPP
#define VSMC_DEFINE_RNG_DISTRIBUTION_2(Name, name, p1, v1, p2, v2)
void logistic_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating logistic random variates.
bool logistic_distribution_check_param(RealType, RealType b)
void u01_distribution(RNGType &, std::size_t, RealType *)
Generate standard uniform random variates.
void div(std::size_t n, const float *a, const float *b, float *y)
void sub(std::size_t n, const float *a, const float *b, float *y)
void fma(std::size_t n, const T *a, const T *b, const T *c, T *y)
For , compute .
Standard uniform distribution.
#define VSMC_DEFINE_RNG_DISTRIBUTION_RAND_2(Name, name, p1, p2)
void log(std::size_t n, const float *a, float *y)
void logistic_distribution_impl(RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)