32 #ifndef VSMC_RNG_LAPLACE_DISTRIBUTION_HPP 33 #define VSMC_RNG_LAPLACE_DISTRIBUTION_HPP 38 #define VSMC_RUNTIME_ASSERT_RNG_LAPLACE_DISTRIBUTION_PARAM_CHECK(b) \ 39 VSMC_RUNTIME_ASSERT((b > 0), "**LaplaceDistribution** CONSTRUCTED " \ 40 "WITH INVALID SCALE PARAMETER VALUE") 48 template <
typename RealType>
58 template <
typename RealType>
67 return std::numeric_limits<result_type>::lowest();
75 template <
typename RNGType>
81 return u > 0 ? param.
a() - param.
b() *
std::log(1 - 2 * u) :
89 template <std::
size_t K,
typename RealType,
typename RNGType>
91 RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
95 sub(n, r, static_cast<RealType>(0.5), r);
96 for (std::size_t i = 0; i != n; ++i) {
106 fma(n, s.data(), r, a, r);
118 #endif // VSMC_RNG_LAPLACE_DISTRIBUTION_HPP
bool laplace_distribution_check_param(RealType, RealType b)
#define VSMC_DEFINE_RNG_DISTRIBUTION_2(Name, name, p1, v1, p2, v2)
#define VSMC_DEFINE_RNG_DISTRIBUTION_IMPL_2(name, p1, p2)
void u01_oo_distribution(RNGType &rng, std::size_t n, RealType *r)
Generate standard uniform random variates on (0, 1)
Standard uniform distribution on (0, 1)
RealType u01(UIntType u) noexcept
Convert uniform unsigned integers to floating points within [0, 1].
#define VSMC_DEFINE_RNG_DISTRIBUTION_MEMBER_0
void laplace_distribution_impl(RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
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 .
#define VSMC_DEFINE_RNG_DISTRIBUTION_RAND_2(Name, name, p1, p2)
std::array with proper alignment
void log(std::size_t n, const float *a, float *y)