3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=US-ASCII">
4 <title>F Distribution
</title>
5 <link rel=
"stylesheet" href=
"../../../math.css" type=
"text/css">
6 <meta name=
"generator" content=
"DocBook XSL Stylesheets V1.77.1">
7 <link rel=
"home" href=
"../../../index.html" title=
"Math Toolkit 2.5.1">
8 <link rel=
"up" href=
"../dists.html" title=
"Distributions">
9 <link rel=
"prev" href=
"extreme_dist.html" title=
"Extreme Value Distribution">
10 <link rel=
"next" href=
"gamma_dist.html" title=
"Gamma (and Erlang) Distribution">
12 <body bgcolor=
"white" text=
"black" link=
"#0000FF" vlink=
"#840084" alink=
"#0000FF">
13 <table cellpadding=
"2" width=
"100%"><tr>
14 <td valign=
"top"><img alt=
"Boost C++ Libraries" width=
"277" height=
"86" src=
"../../../../../../../boost.png"></td>
15 <td align=
"center"><a href=
"../../../../../../../index.html">Home
</a></td>
16 <td align=
"center"><a href=
"../../../../../../../libs/libraries.htm">Libraries
</a></td>
17 <td align=
"center"><a href=
"http://www.boost.org/users/people.html">People
</a></td>
18 <td align=
"center"><a href=
"http://www.boost.org/users/faq.html">FAQ
</a></td>
19 <td align=
"center"><a href=
"../../../../../../../more/index.htm">More
</a></td>
22 <div class=
"spirit-nav">
23 <a accesskey=
"p" href=
"extreme_dist.html"><img src=
"../../../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../dists.html"><img src=
"../../../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../../../index.html"><img src=
"../../../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"gamma_dist.html"><img src=
"../../../../../../../doc/src/images/next.png" alt=
"Next"></a>
26 <div class=
"titlepage"><div><div><h4 class=
"title">
27 <a name=
"math_toolkit.dist_ref.dists.f_dist"></a><a class=
"link" href=
"f_dist.html" title=
"F Distribution">F Distribution
</a>
28 </h4></div></div></div>
29 <pre class=
"programlisting"><span class=
"preprocessor">#include
</span> <span class=
"special"><</span><span class=
"identifier">boost
</span><span class=
"special">/
</span><span class=
"identifier">math
</span><span class=
"special">/
</span><span class=
"identifier">distributions
</span><span class=
"special">/
</span><span class=
"identifier">fisher_f
</span><span class=
"special">.
</span><span class=
"identifier">hpp
</span><span class=
"special">></span></pre>
30 <pre class=
"programlisting"><span class=
"keyword">namespace
</span> <span class=
"identifier">boost
</span><span class=
"special">{
</span> <span class=
"keyword">namespace
</span> <span class=
"identifier">math
</span><span class=
"special">{
</span>
32 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">RealType
</span> <span class=
"special">=
</span> <span class=
"keyword">double
</span><span class=
"special">,
</span>
33 <span class=
"keyword">class
</span> <a class=
"link" href=
"../../../policy.html" title=
"Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy
</a> <span class=
"special">=
</span> <a class=
"link" href=
"../../pol_ref/pol_ref_ref.html" title=
"Policy Class Reference">policies::policy
<></a> <span class=
"special">></span>
34 <span class=
"keyword">class
</span> <span class=
"identifier">fisher_f_distribution
</span><span class=
"special">;
</span>
36 <span class=
"keyword">typedef
</span> <span class=
"identifier">fisher_f_distribution
</span><span class=
"special"><></span> <span class=
"identifier">fisher_f
</span><span class=
"special">;
</span>
38 <span class=
"keyword">template
</span> <span class=
"special"><</span><span class=
"keyword">class
</span> <span class=
"identifier">RealType
</span><span class=
"special">,
</span> <span class=
"keyword">class
</span> <a class=
"link" href=
"../../../policy.html" title=
"Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy
</a><span class=
"special">></span>
39 <span class=
"keyword">class
</span> <span class=
"identifier">fisher_f_distribution
</span>
40 <span class=
"special">{
</span>
41 <span class=
"keyword">public
</span><span class=
"special">:
</span>
42 <span class=
"keyword">typedef
</span> <span class=
"identifier">RealType
</span> <span class=
"identifier">value_type
</span><span class=
"special">;
</span>
44 <span class=
"comment">// Construct:
</span>
45 <span class=
"identifier">fisher_f_distribution
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">RealType
</span><span class=
"special">&</span> <span class=
"identifier">i
</span><span class=
"special">,
</span> <span class=
"keyword">const
</span> <span class=
"identifier">RealType
</span><span class=
"special">&</span> <span class=
"identifier">j
</span><span class=
"special">);
</span>
47 <span class=
"comment">// Accessors:
</span>
48 <span class=
"identifier">RealType
</span> <span class=
"identifier">degrees_of_freedom1
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
49 <span class=
"identifier">RealType
</span> <span class=
"identifier">degrees_of_freedom2
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
50 <span class=
"special">};
</span>
52 <span class=
"special">}}
</span> <span class=
"comment">//namespaces
</span>
55 The F distribution is a continuous distribution that arises when testing
56 whether two samples have the same variance. If
χ<sup>2</sup><sub>m
</sub>   and
χ<sup>2</sup><sub>n
</sub>   are independent
57 variates each distributed as Chi-Squared with
<span class=
"emphasis"><em>m
</em></span> and
58 <span class=
"emphasis"><em>n
</em></span> degrees of freedom, then the test statistic:
61 F
<sub>n,m
</sub>   = (
χ<sup>2</sup><sub>n
</sub>   / n) / (
χ<sup>2</sup><sub>m
</sub>   / m)
64 Is distributed over the range [
0,
∞] with an F distribution, and has the
68 <span class=
"inlinemediaobject"><img src=
"../../../../equations/fisher_pdf.svg"></span>
71 The following graph illustrates how the PDF varies depending on the two
72 degrees of freedom parameters.
75 <span class=
"inlinemediaobject"><img src=
"../../../../graphs/fisher_f_pdf.svg" align=
"middle"></span>
78 <a name=
"math_toolkit.dist_ref.dists.f_dist.h0"></a>
79 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.f_dist.member_functions"></a></span><a class=
"link" href=
"f_dist.html#math_toolkit.dist_ref.dists.f_dist.member_functions">Member Functions
</a>
81 <pre class=
"programlisting"><span class=
"identifier">fisher_f_distribution
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">RealType
</span><span class=
"special">&</span> <span class=
"identifier">df1
</span><span class=
"special">,
</span> <span class=
"keyword">const
</span> <span class=
"identifier">RealType
</span><span class=
"special">&</span> <span class=
"identifier">df2
</span><span class=
"special">);
</span>
84 Constructs an F-distribution with numerator degrees of freedom
<span class=
"emphasis"><em>df1
</em></span>
85 and denominator degrees of freedom
<span class=
"emphasis"><em>df2
</em></span>.
88 Requires that
<span class=
"emphasis"><em>df1
</em></span> and
<span class=
"emphasis"><em>df2
</em></span> are
89 both greater than zero, otherwise
<a class=
"link" href=
"../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error
</a>
92 <pre class=
"programlisting"><span class=
"identifier">RealType
</span> <span class=
"identifier">degrees_of_freedom1
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
95 Returns the numerator degrees of freedom parameter of the distribution.
97 <pre class=
"programlisting"><span class=
"identifier">RealType
</span> <span class=
"identifier">degrees_of_freedom2
</span><span class=
"special">()
</span><span class=
"keyword">const
</span><span class=
"special">;
</span>
100 Returns the denominator degrees of freedom parameter of the distribution.
103 <a name=
"math_toolkit.dist_ref.dists.f_dist.h1"></a>
104 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.f_dist.non_member_accessors"></a></span><a class=
"link" href=
"f_dist.html#math_toolkit.dist_ref.dists.f_dist.non_member_accessors">Non-member
108 All the
<a class=
"link" href=
"../nmp.html" title=
"Non-Member Properties">usual non-member accessor
109 functions
</a> that are generic to all distributions are supported:
110 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function
</a>,
111 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function
</a>,
112 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function
</a>,
113 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.mean">mean
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.median">median
</a>,
114 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.mode">mode
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.variance">variance
</a>,
115 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation
</a>,
116 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis
</a>,
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess
</a>,
117 <a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.range">range
</a> and
<a class=
"link" href=
"../nmp.html#math_toolkit.dist_ref.nmp.support">support
</a>.
120 The domain of the random variable is [
0, +
∞].
123 <a name=
"math_toolkit.dist_ref.dists.f_dist.h2"></a>
124 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.f_dist.examples"></a></span><a class=
"link" href=
"f_dist.html#math_toolkit.dist_ref.dists.f_dist.examples">Examples
</a>
127 Various
<a class=
"link" href=
"../../stat_tut/weg/f_eg.html" title=
"F Distribution Examples">worked examples
</a>
128 are available illustrating the use of the F Distribution.
131 <a name=
"math_toolkit.dist_ref.dists.f_dist.h3"></a>
132 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.f_dist.accuracy"></a></span><a class=
"link" href=
"f_dist.html#math_toolkit.dist_ref.dists.f_dist.accuracy">Accuracy
</a>
135 The normal distribution is implemented in terms of the
<a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">incomplete
136 beta function
</a> and its
<a class=
"link" href=
"../../sf_beta/ibeta_inv_function.html" title=
"The Incomplete Beta Function Inverses">inverses
</a>,
137 refer to those functions for accuracy data.
140 <a name=
"math_toolkit.dist_ref.dists.f_dist.h4"></a>
141 <span class=
"phrase"><a name=
"math_toolkit.dist_ref.dists.f_dist.implementation"></a></span><a class=
"link" href=
"f_dist.html#math_toolkit.dist_ref.dists.f_dist.implementation">Implementation
</a>
144 In the following table
<span class=
"emphasis"><em>v1
</em></span> and
<span class=
"emphasis"><em>v2
</em></span>
145 are the first and second degrees of freedom parameters of the distribution,
146 <span class=
"emphasis"><em>x
</em></span> is the random variate,
<span class=
"emphasis"><em>p
</em></span> is
147 the probability, and
<span class=
"emphasis"><em>q =
1-p
</em></span>.
149 <div class=
"informaltable"><table class=
"table">
175 The usual form of the PDF is given by:
178 <span class=
"inlinemediaobject"><img src=
"../../../../equations/fisher_pdf.svg"></span>
181 However, that form is hard to evaluate directly without incurring
182 problems with either accuracy or numeric overflow.
185 Direct differentiation of the CDF expressed in terms of the incomplete
189 led to the following two formulas:
192 f
<sub>v1,v2
</sub>(x) = y *
<a class=
"link" href=
"../../sf_beta/beta_derivative.html" title=
"Derivative of the Incomplete Beta Function">ibeta_derivative
</a>(v2
193 /
2, v1 /
2, v2 / (v2 + v1 * x))
196 with y = (v2 * v1) / ((v2 + v1 * x) * (v2 + v1 * x))
202 f
<sub>v1,v2
</sub>(x) = y *
<a class=
"link" href=
"../../sf_beta/beta_derivative.html" title=
"Derivative of the Incomplete Beta Function">ibeta_derivative
</a>(v1
203 /
2, v2 /
2, v1 * x / (v2 + v1 * x))
206 with y = (z * v1 - x * v1 * v1) / z
<sup>2</sup>
212 The first of these is used for v1 * x
> v2, otherwise the
216 The aim is to keep the
<span class=
"emphasis"><em>x
</em></span> argument to
<a class=
"link" href=
"../../sf_beta/beta_derivative.html" title=
"Derivative of the Incomplete Beta Function">ibeta_derivative
</a>
217 away from
1 to avoid rounding error.
232 p =
<a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">ibeta
</a>(v1
233 /
2, v2 /
2, v1 * x / (v2 + v1 * x))
239 p =
<a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">ibetac
</a>(v2
240 /
2, v1 /
2, v2 / (v2 + v1 * x))
243 The first is used for v1 * x
> v2, otherwise the second is
247 The aim is to keep the
<span class=
"emphasis"><em>x
</em></span> argument to
<a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">ibeta
</a> well
248 away from
1 to avoid rounding error.
263 p =
<a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">ibetac
</a>(v1
264 /
2, v2 /
2, v1 * x / (v2 + v1 * x))
270 p =
<a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">ibeta
</a>(v2
271 /
2, v1 /
2, v2 / (v2 + v1 * x))
274 The first is used for v1 * x
< v2, otherwise the second is
278 The aim is to keep the
<span class=
"emphasis"><em>x
</em></span> argument to
<a class=
"link" href=
"../../sf_beta/ibeta_function.html" title=
"Incomplete Beta Functions">ibeta
</a> well
279 away from
1 to avoid rounding error.
294 x = v2 * a / (v1 * b)
300 a =
<a class=
"link" href=
"../../sf_beta/ibeta_inv_function.html" title=
"The Incomplete Beta Function Inverses">ibeta_inv
</a>(v1
310 Quantities
<span class=
"emphasis"><em>a
</em></span> and
<span class=
"emphasis"><em>b
</em></span>
311 are both computed by
<a class=
"link" href=
"../../sf_beta/ibeta_inv_function.html" title=
"The Incomplete Beta Function Inverses">ibeta_inv
</a>
312 without the subtraction implied above.
330 x = v2 * a / (v1 * b)
336 a =
<a class=
"link" href=
"../../sf_beta/ibeta_inv_function.html" title=
"The Incomplete Beta Function Inverses">ibetac_inv
</a>(v1
346 Quantities
<span class=
"emphasis"><em>a
</em></span> and
<span class=
"emphasis"><em>b
</em></span>
347 are both computed by
<a class=
"link" href=
"../../sf_beta/ibeta_inv_function.html" title=
"The Incomplete Beta Function Inverses">ibetac_inv
</a>
348 without the subtraction implied above.
372 2 * v2
<sup>2 </sup> * (v1 + v2 -
2) / (v1 * (v2 -
2) * (v2 -
2) * (v2 -
4))
384 v2 * (v1 -
2) / (v1 * (v2 +
2))
396 2 * (v2 +
2 * v1 -
2) * sqrt((
2 * v2 -
8) / (v1 * (v2 + v1 -
404 kurtosis and kurtosis excess
409 Refer to,
<a href=
"http://mathworld.wolfram.com/F-Distribution.html" target=
"_top">Weisstein,
410 Eric W.
"F-Distribution." From MathWorld--A Wolfram
418 <table xmlns:
rev=
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
"100%"><tr>
419 <td align=
"left"></td>
420 <td align=
"right"><div class=
"copyright-footer">Copyright
© 2006-
2010,
2012-
2014 Nikhar Agrawal,
421 Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
422 Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan R
åde, Gautam Sewani,
423 Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang
<p>
424 Distributed under the Boost Software License, Version
1.0. (See accompanying
425 file LICENSE_1_0.txt or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt" target=
"_top">http://www.boost.org/LICENSE_1_0.txt
</a>)
430 <div class=
"spirit-nav">
431 <a accesskey=
"p" href=
"extreme_dist.html"><img src=
"../../../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../dists.html"><img src=
"../../../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../../../index.html"><img src=
"../../../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"gamma_dist.html"><img src=
"../../../../../../../doc/src/images/next.png" alt=
"Next"></a>