32 #ifndef MCKL_RANDOM_POKER_TEST_HPP 33 #define MCKL_RANDOM_POKER_TEST_HPP 46 template <std::
size_t D, std::
size_t T>
49 static_assert(D > 1,
"**PockerTest** used with D less than two");
51 static_assert(T > 0,
"**PockerTest** used with T equal to zero");
54 PokerTest(std::size_t n) : n_(n), tmin_(0), tmax_(0)
61 for (std::size_t k = 1; k <= K_; ++k, d -= 1) {
63 np_all[k - 1] = mult * stirling(T, k);
70 template <
typename RNGType,
typename U01DistributionType>
73 using result_type =
typename U01DistributionType::result_type;
76 const std::size_t m = n_ / k;
77 const std::size_t l = n_ % k;
79 count_.resize(np_.size());
80 std::fill(count_.begin(), count_.end(), 0);
81 for (std::size_t i = 0; i != m; ++i) {
82 generate(rng, u01, k, r.data());
84 generate(rng, u01, l, r.data());
86 return this->
stat(np_.size(), count_.data(), np_.data());
91 return static_cast<double>(np_.size() - 1);
95 static constexpr std::size_t K_ = D < T ? D : T;
103 template <
typename RNGType,
typename U01DistributionType>
104 void generate(RNGType &rng, U01DistributionType &
u01, std::size_t n,
105 typename U01DistributionType::result_type *r)
107 rand(rng, u01, n * T, r);
108 mul(n * T, static_cast<typename U01DistributionType::result_type>(D),
110 for (std::size_t i = 0; i != n; ++i, r += T) {
111 std::size_t t = index(r);
114 }
else if (t >= tmax_) {
117 count_[t - tmin_] += 1;
122 template <
typename ResultType>
123 std::size_t index(
const ResultType *r)
const 125 std::bitset<D> occurs;
126 set<0>(r, occurs, std::integral_constant<bool, 0 < T>());
128 return occurs.count() - 1;
131 template <std::
size_t N,
typename ResultType>
132 void set(
const ResultType *, std::bitset<D> &, std::false_type)
const 136 template <std::
size_t N,
typename ResultType>
137 void set(
const ResultType *r, std::bitset<D> &occurs, std::true_type)
const 139 std::size_t u = internal::ftoi<std::size_t, D>(r[N]);
141 set<N + 1>(r, occurs, std::integral_constant<bool, N + 1 < T>());
147 #endif // MCKL_RANDOM_POKER_TEST_HPP
void pow(std::size_t n, const float *a, const float *b, float *y)
void mul(std::size_t n, const float *a, const float *b, float *y)
double stat(std::size_t m, const double *count, const double *np) const
void group_np(double n, const Vector< double > &np_all, Vector< double > &np, std::size_t &kmin, std::size_t &kmax)
std::vector< T, Alloc > Vector
std::vector with Allocator as the default allocator
double degree_of_freedom() const
double operator()(RNGType &rng, U01DistributionType &u01)
RealType u01(UIntType u)
Convert uniform unsigned integers to floating points within [0, 1].
#define MCKL_DEFINE_RANDOM_TEST_OPERATOR(ResultType)
Pocker test (simplified version)
void rand(RNGType &rng, ArcsineDistribution< RealType > &distribution, std::size_t N, RealType *r)
Tests based on the -distribution.