32 #ifndef MCKL_RANDOM_CHI_SQUARED_TEST_HPP 33 #define MCKL_RANDOM_CHI_SQUARED_TEST_HPP 41 template <
typename Derived>
51 return std::min(p, 1 - p) > 0.5 * alpha;
57 0.5 *
static_cast<const Derived *
>(
this)->degree_of_freedom();
67 0.5 * static_cast<const Derived *>(
this)->degree_of_freedom(),
72 double stat(std::size_t m,
const double *count,
const double *np)
const 74 return stat_dispatch(m, count, np);
77 double stat(std::size_t m,
const double *count,
double np)
const 79 return stat_dispatch(m, count, np);
83 template <
typename NPType>
84 double stat_dispatch(std::size_t m,
const double *count, NPType np)
const 87 sub(m, count, np, tmp.data());
88 sqr(m, tmp.data(), tmp.data());
89 div(m, tmp.data(), np, tmp.data());
91 return std::accumulate(tmp.begin(), tmp.end(), 0.0);
97 #endif // MCKL_RANDOM_CHI_SQUARED_TEST_HPP
double stat(std::size_t m, const double *count, const double *np) const
void lgamma(std::size_t n, const float *a, 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
double pdf(result_type s) const
double gammap(double a, double x)
Regularized lower incomplete Gamma function.
void sub(std::size_t n, const float *a, const float *b, float *y)
bool pass(double alpha, result_type s) const
double stat(std::size_t m, const double *count, double np) const
void sqr(std::size_t n, const float *a, float *y)
double cdf(result_type s) const
void exp(std::size_t n, const float *a, float *y)
Tests based on the -distribution.
void div(std::size_t n, const float *a, const float *b, float *y)