32 #ifndef VSMC_RNG_FISHER_F_DISTRIBUTION_HPP 33 #define VSMC_RNG_FISHER_F_DISTRIBUTION_HPP 44 template <
typename RealType>
47 return m > 0 && n > 0;
54 template <
typename RealType>
74 template <
typename RNGType>
78 return (chi_squared_m_(rng) / m()) / (chi_squared_n_(rng) / n());
83 return (chi_squared_m(rng) / param.
m()) /
84 (chi_squared_n(rng) / param.
n());
91 template <std::
size_t K,
typename RealType,
typename RNGType>
93 RNGType &rng, std::size_t n, RealType *r, RealType df1, RealType df2)
98 mul(n, 1 / df1, s, s);
99 mul(n, 1 / df2, r, r);
107 template <
typename RealType,
typename RNGType>
109 RNGType &rng, std::size_t n, RealType *r, RealType df1, RealType df2)
111 static_assert(std::is_floating_point<RealType>::value,
112 "**fisher_f_distribution** USED WITH RealType OTHER THAN FLOATING " 115 const std::size_t k = 1024;
116 const std::size_t m = n / k;
117 const std::size_t l = n % k;
118 for (std::size_t i = 0; i != m; ++i, r += k)
119 internal::fisher_f_distribution_impl<k>(rng, k, r, df1, df2);
120 internal::fisher_f_distribution_impl<k>(rng, l, r, df1, df2);
127 #endif // VSMC_RNG_FISHER_F_DISTRIBUTION_HPP bool fisher_f_distribution_check_param(RealType m, RealType n)
void mul(std::size_t n, const float *a, const float *b, float *y)
#define VSMC_DEFINE_RNG_DISTRIBUTION_2(Name, name, p1, v1, p2, v2)
void div(std::size_t n, const float *a, const float *b, float *y)
void chi_squared_distribution(RNGType &rng, std::size_t n, RealType *r, RealType df)
Generating random variates.
#define VSMC_DEFINE_RNG_DISTRIBUTION_RAND_2(Name, name, p1, p2)
void fisher_f_distribution(RNGType &rng, std::size_t n, RealType *r, RealType df1, RealType df2)
Generating Fisher-F random variates.
void fisher_f_distribution_impl(RNGType &rng, std::size_t n, RealType *r, RealType df1, RealType df2)