32 #ifndef MCKL_RANDOM_COUPON_COLLECTOR_TEST_HPP 33 #define MCKL_RANDOM_COUPON_COLLECTOR_TEST_HPP 45 template <std::size_t D,
46 std::size_t NTrialMax = std::numeric_limits<std::size_t>::max()>
50 static_assert(D > 1,
"**CouponCollectorTest** used with D less than two");
60 for (std::size_t k = D; k < T_; ++k) {
62 n *
std::exp(lfact - k * ld) * stirling(k - 1, D - 1);
65 n - std::accumulate(np_all.data(), np_all.data() + T_ - D, 0.0);
71 template <
typename RNGType,
typename U01DistributionType>
74 using result_type =
typename U01DistributionType::result_type;
78 count_.resize(np_.size());
79 std::fill(count_.begin(), count_.end(), 0);
86 std::bitset<D> occurs;
92 rand(rng, u01, k, r.data());
93 mul(k, static_cast<double>(D), r.data(), r.data());
97 std::size_t u = internal::ftoi<std::size_t, D>(r[uidx++]);
98 if (!occurs.test(u)) {
106 }
else if (t >= tmax_) {
109 count_[t - tmin_] += 1;
117 return this->
stat(np_.size(), count_.data(), np_.data());
122 return static_cast<double>(np_.size() - 1);
126 static constexpr std::size_t T_ = D + 256;
137 #endif // MCKL_RANDOM_COUPON_COLLECTOR_TEST_HPP
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)
void lgamma(std::size_t n, const float *a, float *y)
double operator()(RNGType &rng, U01DistributionType &u01)
CouponCollectorTest(std::size_t n)
std::vector< T, Alloc > Vector
std::vector with Allocator as the default allocator
void log(std::size_t n, const float *a, float *y)
RealType u01(UIntType u)
Convert uniform unsigned integers to floating points within [0, 1].
double degree_of_freedom() const
#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)
Coupon collector's test.
Tests based on the -distribution.