32 #ifndef MCKL_RANDOM_BIRTHDAY_SPACINGS_TEST_HPP 33 #define MCKL_RANDOM_BIRTHDAY_SPACINGS_TEST_HPP 45 template <std::
size_t D, std::
size_t T>
48 static_assert(D > 1,
"**BirthdaySpacingsTest** used with D less than two");
50 static_assert(T > 0,
"**BirthdaySpacingsTest** used with T equal to zero");
61 template <
typename RNGType,
typename U01DistributionType>
64 using result_type =
typename U01DistributionType::result_type;
67 const std::size_t m = n_ / k;
68 const std::size_t l = n_ % k;
71 std::size_t *s = spacings.data();
72 for (std::size_t i = 0; i != m; ++i, s += k) {
73 generate(rng, u01, k, r.data(), s);
75 generate(rng, u01, l, r.data(), s);
77 std::size_t d0 = spacings.front();
78 std::sort(spacings.begin(), spacings.end());
79 for (std::size_t i = 0; i != n_ - 1; ++i) {
80 spacings[i] = spacings[i + 1] - spacings[i];
82 spacings.back() = K_ - spacings.back() + d0;
83 std::sort(spacings.begin(), spacings.end());
85 for (std::size_t i = 0; i != n_ - 1; ++i) {
86 if (spacings[i] == spacings[i + 1]) {
94 double mean()
const {
return mean_; }
102 template <
typename RNGType,
typename U01DistributionType>
103 void generate(RNGType &rng, U01DistributionType &
u01, std::size_t n,
104 typename U01DistributionType::result_type *r, std::size_t *s)
106 rand(rng, u01, n * T, r);
107 mul(n * T, static_cast<typename U01DistributionType::result_type>(D),
109 for (std::size_t i = 0; i != n; ++i, r += T) {
110 s[i] = internal::serial_index<D, T>(r);
117 #endif // MCKL_RANDOM_BIRTHDAY_SPACINGS_TEST_HPP
void mul(std::size_t n, const float *a, const float *b, float *y)
std::vector< T, Alloc > Vector
std::vector with Allocator as the default allocator
void log(std::size_t n, const float *a, float *y)
constexpr double const_ln_2< double >() noexcept
RealType u01(UIntType u)
Convert uniform unsigned integers to floating points within [0, 1].
#define MCKL_DEFINE_RANDOM_TEST_OPERATOR(ResultType)
void exp(std::size_t n, const float *a, float *y)
void rand(RNGType &rng, ArcsineDistribution< RealType > &distribution, std::size_t N, RealType *r)
BirthdaySpacingsTest(std::size_t n)
Tests based on the Poisson distribution.
std::size_t operator()(RNGType &rng, U01DistributionType &u01)