32 #ifndef MCKL_RANDOM_GAP_TEST_HPP 33 #define MCKL_RANDOM_GAP_TEST_HPP 44 template <std::size_t NTrialMax = std::numeric_limits<std::size_t>::max()>
60 GapTest(std::size_t n,
double alpha,
double beta)
61 : n_(n), alpha_(alpha), beta_(beta)
64 alpha >= 0,
"GapTest used with alpha smaller than zero");
66 runtime_assert(beta <= 1,
"GapTest used with beta larger than one");
69 alpha < beta,
"GapTest used with alpha not less than beta");
71 double p = beta - alpha;
85 mul(np_.size(),
static_cast<double>(n), np_.data(), np_.data());
86 np_.push_back(n - std::accumulate(np_.begin(), np_.end(), 0.0));
91 template <
typename RNGType,
typename U01DistributionType>
94 using result_type =
typename U01DistributionType::result_type;
96 const std::size_t t = np_.size() - 1;
97 count_.resize(np_.size());
98 std::fill(count_.begin(), count_.end(), 0);
104 if (r >= NTrialMax) {
108 if (u >= alpha_ && u < beta_) {
109 count_[std::min(r, t)] += 1;
117 return this->stat(t + 1, count_.data(), np_.data());
122 return static_cast<double>(np_.size() - 1);
135 #endif // MCKL_RANDOM_GAP_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
double degree_of_freedom() const
RealType u01(UIntType u)
Convert uniform unsigned integers to floating points within [0, 1].
GapTest(std::size_t n, double alpha, double beta)
Construct a Gap test.
double operator()(RNGType &rng, U01DistributionType &u01)
#define MCKL_DEFINE_RANDOM_TEST_OPERATOR(ResultType)
Tests based on the -distribution.
void runtime_assert(bool cond, const char *msg, bool soft=false)