1 [section:f_dist F Distribution]
3 ``#include <boost/math/distributions/fisher_f.hpp>``
5 namespace boost{ namespace math{
7 template <class RealType = double,
8 class ``__Policy`` = ``__policy_class`` >
9 class fisher_f_distribution;
11 typedef fisher_f_distribution<> fisher_f;
13 template <class RealType, class ``__Policy``>
14 class fisher_f_distribution
17 typedef RealType value_type;
20 fisher_f_distribution(const RealType& i, const RealType& j);
23 RealType degrees_of_freedom1()const;
24 RealType degrees_of_freedom2()const;
29 The F distribution is a continuous distribution that arises when testing
30 whether two samples have the same variance. If [chi][super 2][sub m][space] and
31 [chi][super 2][sub n][space] are independent variates each distributed as
32 Chi-Squared with /m/ and /n/ degrees of freedom, then the test statistic:
34 F[sub n,m][space] = ([chi][super 2][sub n][space] / n) / ([chi][super 2][sub m][space] / m)
36 Is distributed over the range \[0, [infin]\] with an F distribution, and
41 The following graph illustrates how the PDF varies depending on the
42 two degrees of freedom parameters.
49 fisher_f_distribution(const RealType& df1, const RealType& df2);
51 Constructs an F-distribution with numerator degrees of freedom /df1/
52 and denominator degrees of freedom /df2/.
54 Requires that /df1/ and /df2/ are both greater than zero, otherwise __domain_error
57 RealType degrees_of_freedom1()const;
59 Returns the numerator degrees of freedom parameter of the distribution.
61 RealType degrees_of_freedom2()const;
63 Returns the denominator degrees of freedom parameter of the distribution.
65 [h4 Non-member Accessors]
67 All the [link math_toolkit.dist.dist_ref.nmp usual non-member accessor functions]
68 that are generic to all distributions are supported: __usual_accessors.
70 The domain of the random variable is \[0, +[infin]\].
74 Various [link math_toolkit.dist.stat_tut.weg.f_eg worked examples] are
75 available illustrating the use of the F Distribution.
79 The normal distribution is implemented in terms of the
80 [link math_toolkit.special.sf_beta.ibeta_function incomplete beta function]
81 and its [link math_toolkit.special.sf_beta.ibeta_inv_function inverses],
82 refer to those functions for accuracy data.
86 In the following table /v1/ and /v2/ are the first and second
87 degrees of freedom parameters of the distribution,
88 /x/ is the random variate, /p/ is the probability, and /q = 1-p/.
91 [[Function][Implementation Notes]]
92 [[pdf][The usual form of the PDF is given by:
96 However, that form is hard to evaluate directly without incurring problems with
97 either accuracy or numeric overflow.
99 Direct differentiation of the CDF expressed in terms of the incomplete beta function
101 led to the following two formulas:
103 f[sub v1,v2](x) = y * __ibeta_derivative(v2 \/ 2, v1 \/ 2, v2 \/ (v2 + v1 * x))
105 with y = (v2 * v1) \/ ((v2 + v1 * x) * (v2 + v1 * x))
109 f[sub v1,v2](x) = y * __ibeta_derivative(v1 \/ 2, v2 \/ 2, v1 * x \/ (v2 + v1 * x))
111 with y = (z * v1 - x * v1 * v1) \/ z[super 2]
115 The first of these is used for v1 * x > v2, otherwise the second is used.
117 The aim is to keep the /x/ argument to __ibeta_derivative away from 1 to avoid
119 [[cdf][Using the relations:
121 p = __ibeta(v1 \/ 2, v2 \/ 2, v1 * x \/ (v2 + v1 * x))
125 p = __ibetac(v2 \/ 2, v1 \/ 2, v2 \/ (v2 + v1 * x))
127 The first is used for v1 * x > v2, otherwise the second is used.
129 The aim is to keep the /x/ argument to __ibeta well away from 1 to
130 avoid rounding error. ]]
132 [[cdf complement][Using the relations:
134 p = __ibetac(v1 \/ 2, v2 \/ 2, v1 * x \/ (v2 + v1 * x))
138 p = __ibeta(v2 \/ 2, v1 \/ 2, v2 \/ (v2 + v1 * x))
140 The first is used for v1 * x < v2, otherwise the second is used.
142 The aim is to keep the /x/ argument to __ibeta well away from 1 to
143 avoid rounding error. ]]
144 [[quantile][Using the relation:
146 x = v2 * a \/ (v1 * b)
150 a = __ibeta_inv(v1 \/ 2, v2 \/ 2, p)
156 Quantities /a/ and /b/ are both computed by __ibeta_inv without the
157 subtraction implied above.]]
160 from the complement][Using the relation:
162 x = v2 * a \/ (v1 * b)
166 a = __ibetac_inv(v1 \/ 2, v2 \/ 2, p)
172 Quantities /a/ and /b/ are both computed by __ibetac_inv without the
173 subtraction implied above.]]
174 [[mean][v2 \/ (v2 - 2)]]
175 [[variance][2 * v2[super 2 ] * (v1 + v2 - 2) \/ (v1 * (v2 - 2) * (v2 - 2) * (v2 - 4))]]
176 [[mode][v2 * (v1 - 2) \/ (v1 * (v2 + 2))]]
177 [[skewness][2 * (v2 + 2 * v1 - 2) * sqrt((2 * v2 - 8) \/ (v1 * (v2 + v1 - 2))) \/ (v2 - 6)]]
178 [[kurtosis and kurtosis excess]
179 [Refer to, [@http://mathworld.wolfram.com/F-Distribution.html
180 Weisstein, Eric W. "F-Distribution." From MathWorld--A Wolfram Web Resource.] ]]
183 [endsect][/section:f_dist F distribution]
186 Copyright 2006 John Maddock and Paul A. Bristow.
187 Distributed under the Boost Software License, Version 1.0.
188 (See accompanying file LICENSE_1_0.txt or copy at
189 http://www.boost.org/LICENSE_1_0.txt).