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, const param_type& parm);
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;
60 std::vector<D::result_type> u;
61 for (int i = 0; i < N; ++i)
63 D::result_type v = d(g, p);
67 std::sort(u.begin(), u.end());
68 for (int i = 0; i < N; ++i)
69 assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
72 typedef std::fisher_f_distribution<> D;
73 typedef D::param_type P;
74 typedef std::mt19937 G;
79 std::vector<D::result_type> u;
80 for (int i = 0; i < N; ++i)
82 D::result_type v = d(g, p);
86 std::sort(u.begin(), u.end());
87 for (int i = 0; i < N; ++i)
88 assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
91 typedef std::fisher_f_distribution<> D;
92 typedef D::param_type P;
93 typedef std::mt19937 G;
98 std::vector<D::result_type> u;
99 for (int i = 0; i < N; ++i)
101 D::result_type v = d(g, p);
105 std::sort(u.begin(), u.end());
106 for (int i = 0; i < N; ++i)
107 assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);