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.79.1">
7 <link rel="home" href="../../../index.html" title="Math Toolkit 2.11.0">
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 20. 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 20. 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:
60 <div class="blockquote"><blockquote class="blockquote"><p>
61 <span class="serif_italic">F<sub>n,m</sub> = (χ<sup>2</sup><sub>n</sub> / n) / (χ<sup>2</sup><sub>m</sub> / m)</span>
62 </p></blockquote></div>
64 Is distributed over the range [0, ∞] with an F distribution, and has the
67 <div class="blockquote"><blockquote class="blockquote"><p>
68 <span class="inlinemediaobject"><img src="../../../../equations/fisher_pdf.svg"></span>
70 </p></blockquote></div>
72 The following graph illustrates how the PDF varies depending on the two
73 degrees of freedom parameters.
75 <div class="blockquote"><blockquote class="blockquote"><p>
76 <span class="inlinemediaobject"><img src="../../../../graphs/fisher_f_pdf.svg" align="middle"></span>
78 </p></blockquote></div>
80 <a name="math_toolkit.dist_ref.dists.f_dist.h0"></a>
81 <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>
83 <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>
86 Constructs an F-distribution with numerator degrees of freedom <span class="emphasis"><em>df1</em></span>
87 and denominator degrees of freedom <span class="emphasis"><em>df2</em></span>.
90 Requires that <span class="emphasis"><em>df1</em></span> and <span class="emphasis"><em>df2</em></span> are
91 both greater than zero, otherwise <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
94 <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>
97 Returns the numerator degrees of freedom parameter of the distribution.
99 <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>
102 Returns the denominator degrees of freedom parameter of the distribution.
105 <a name="math_toolkit.dist_ref.dists.f_dist.h1"></a>
106 <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
110 All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
111 functions</a> that are generic to all distributions are supported:
112 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
113 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
114 <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>,
115 <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>,
116 <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>,
117 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
118 <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>,
119 <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>.
122 The domain of the random variable is [0, +∞].
125 <a name="math_toolkit.dist_ref.dists.f_dist.h2"></a>
126 <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>
129 Various <a class="link" href="../../stat_tut/weg/f_eg.html" title="F Distribution Examples">worked examples</a>
130 are available illustrating the use of the F Distribution.
133 <a name="math_toolkit.dist_ref.dists.f_dist.h3"></a>
134 <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>
137 The normal distribution is implemented in terms of the <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">incomplete
138 beta function</a> and its <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">inverses</a>,
139 refer to those functions for accuracy data.
142 <a name="math_toolkit.dist_ref.dists.f_dist.h4"></a>
143 <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>
146 In the following table <span class="emphasis"><em>v1</em></span> and <span class="emphasis"><em>v2</em></span>
147 are the first and second degrees of freedom parameters of the distribution,
148 <span class="emphasis"><em>x</em></span> is the random variate, <span class="emphasis"><em>p</em></span> is
149 the probability, and <span class="emphasis"><em>q = 1-p</em></span>.
151 <div class="informaltable"><table class="table">
177 The usual form of the PDF is given by:
179 <div class="blockquote"><blockquote class="blockquote"><p>
180 <span class="inlinemediaobject"><img src="../../../../equations/fisher_pdf.svg"></span>
182 </p></blockquote></div>
184 However, that form is hard to evaluate directly without incurring
185 problems with either accuracy or numeric overflow.
188 Direct differentiation of the CDF expressed in terms of the incomplete
192 led to the following two formulas:
194 <div class="blockquote"><blockquote class="blockquote"><p>
195 <span class="serif_italic">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
196 / 2, v1 / 2, v2 / (v2 + v1 * x))</span>
197 </p></blockquote></div>
199 with y = (v2 * v1) / ((v2 + v1 * x) * (v2 + v1 * x))
204 <div class="blockquote"><blockquote class="blockquote"><p>
205 <span class="serif_italic">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
206 / 2, v2 / 2, v1 * x / (v2 + v1 * x))</span>
207 </p></blockquote></div>
209 with y = (z * v1 - x * v1 * v1) / z<sup>2</sup>
215 The first of these is used for v1 * x > v2, otherwise the
219 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>
220 away from 1 to avoid rounding error.
234 <div class="blockquote"><blockquote class="blockquote"><p>
235 <span class="serif_italic">p = <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>(v1
236 / 2, v2 / 2, v1 * x / (v2 + v1 * x))</span>
237 </p></blockquote></div>
241 <div class="blockquote"><blockquote class="blockquote"><p>
242 <span class="serif_italic">:p = <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>(v2
243 / 2, v1 / 2, v2 / (v2 + v1 * x))</span>
244 </p></blockquote></div>
246 The first is used for v1 * x > v2, otherwise the second is
250 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
251 away from 1 to avoid rounding error.
265 <div class="blockquote"><blockquote class="blockquote"><p>
266 <span class="serif_italic">p = <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>(v1
267 / 2, v2 / 2, v1 * x / (v2 + v1 * x))</span>
268 </p></blockquote></div>
272 <div class="blockquote"><blockquote class="blockquote"><p>
273 <span class="serif_italic">p = <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>(v2
274 / 2, v1 / 2, v2 / (v2 + v1 * x))</span>
275 </p></blockquote></div>
277 The first is used for v1 * x < v2, otherwise the second is
281 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
282 away from 1 to avoid rounding error.
296 <div class="blockquote"><blockquote class="blockquote"><p>
297 <span class="serif_italic">x = v2 * a / (v1 * b)</span>
298 </p></blockquote></div>
302 <div class="blockquote"><blockquote class="blockquote"><p>
303 <span class="serif_italic">a = <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inv</a>(v1
304 / 2, v2 / 2, p)</span>
305 </p></blockquote></div>
309 <div class="blockquote"><blockquote class="blockquote"><p>
310 <span class="serif_italic">b = 1 - a</span>
311 </p></blockquote></div>
313 Quantities <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>
314 are both computed by <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inv</a>
315 without the subtraction implied above.
332 <div class="blockquote"><blockquote class="blockquote"><p>
333 <span class="serif_italic">x = v2 * a / (v1 * b)</span>
334 </p></blockquote></div>
338 <div class="blockquote"><blockquote class="blockquote"><p>
339 <span class="serif_italic">a = <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibetac_inv</a>(v1
340 / 2, v2 / 2, p)</span>
341 </p></blockquote></div>
345 <div class="blockquote"><blockquote class="blockquote"><p>
346 <span class="serif_italic">b = 1 - a</span>
347 </p></blockquote></div>
349 Quantities <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>
350 are both computed by <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibetac_inv</a>
351 without the subtraction implied above.
375 2 * v2<sup>2 </sup> * (v1 + v2 - 2) / (v1 * (v2 - 2) * (v2 - 2) * (v2 - 4))
387 v2 * (v1 - 2) / (v1 * (v2 + 2))
399 2 * (v2 + 2 * v1 - 2) * sqrt((2 * v2 - 8) / (v1 * (v2 + v1 -
407 kurtosis and kurtosis excess
412 Refer to, <a href="http://mathworld.wolfram.com/F-Distribution.html" target="_top">Weisstein,
413 Eric W. "F-Distribution." From MathWorld--A Wolfram
421 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
422 <td align="left"></td>
423 <td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar
424 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
425 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
426 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
427 Daryle Walker and Xiaogang Zhang<p>
428 Distributed under the Boost Software License, Version 1.0. (See accompanying
429 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>)
434 <div class="spirit-nav">
435 <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>