1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // REQUIRES: long_tests
14 // template<class RealType = double>
15 // class fisher_f_distribution
17 // template<class _URNG> result_type operator()(_URNG& g);
34 I(double x, unsigned a, unsigned b)
37 for (int j = a; static_cast<unsigned>(j) <= a+b-1; ++j)
38 r += fac(a+b-1)/(fac(j) * fac(a + b - 1 - j)) * std::pow(x, j) *
39 std::pow(1-x, a+b-1-j);
44 f(double x, double m, double n)
46 return I(m * x / (m*x + n), static_cast<unsigned>(m/2), static_cast<unsigned>(n/2));
51 // Purposefully only testing even integral values of m and n (for now)
53 typedef std::fisher_f_distribution<> D;
54 typedef D::param_type P;
55 typedef std::mt19937 G;
59 std::vector<D::result_type> u;
60 for (int i = 0; i < N; ++i)
62 D::result_type v = d(g);
66 std::sort(u.begin(), u.end());
67 for (int i = 0; i < N; ++i)
68 assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
71 typedef std::fisher_f_distribution<> D;
72 typedef D::param_type P;
73 typedef std::mt19937 G;
77 std::vector<D::result_type> u;
78 for (int i = 0; i < N; ++i)
80 D::result_type v = d(g);
84 std::sort(u.begin(), u.end());
85 for (int i = 0; i < N; ++i)
86 assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
89 typedef std::fisher_f_distribution<> D;
90 typedef D::param_type P;
91 typedef std::mt19937 G;
95 std::vector<D::result_type> u;
96 for (int i = 0; i < N; ++i)
98 D::result_type v = d(g);
102 std::sort(u.begin(), u.end());
103 for (int i = 0; i < N; ++i)
104 assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);