mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-07 08:24:53 -04:00
Squashed 'boost/' content from commit b4feb19f2
git-subtree-dir: boost git-subtree-split: b4feb19f287ee92d87a9624b5d36b7cf46aeadeb
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Complements are supported too - and when to use them</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../overview.html" title="Overview of Distributions">
|
||||
<link rel="prev" href="generic.html" title="Generic operations common to all distributions are non-member functions">
|
||||
<link rel="next" href="parameters.html" title="Parameters can be calculated">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="generic.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="parameters.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.stat_tut.overview.complements"></a><a class="link" href="complements.html" title="Complements are supported too - and when to use them">Complements
|
||||
are supported too - and when to use them</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Often you don't want the value of the CDF, but its complement, which is
|
||||
to say <code class="computeroutput"><span class="number">1</span><span class="special">-</span><span class="identifier">p</span></code> rather than <code class="computeroutput"><span class="identifier">p</span></code>.
|
||||
It is tempting to calculate the CDF and subtract it from <code class="computeroutput"><span class="number">1</span></code>, but if <code class="computeroutput"><span class="identifier">p</span></code>
|
||||
is very close to <code class="computeroutput"><span class="number">1</span></code> then cancellation
|
||||
error will cause you to lose accuracy, perhaps totally.
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="complements.html#why_complements">See below <span class="emphasis"><em>"Why and when
|
||||
to use complements?"</em></span></a>
|
||||
</p>
|
||||
<p>
|
||||
In this library, whenever you want to receive a complement, just wrap all
|
||||
the function arguments in a call to <code class="computeroutput"><span class="identifier">complement</span><span class="special">(...)</span></code>, for example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">students_t</span> <span class="identifier">dist</span><span class="special">(</span><span class="number">5</span><span class="special">);</span>
|
||||
<span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"CDF at t = 1 is "</span> <span class="special"><<</span> <span class="identifier">cdf</span><span class="special">(</span><span class="identifier">dist</span><span class="special">,</span> <span class="number">1.0</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
|
||||
<span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Complement of CDF at t = 1 is "</span> <span class="special"><<</span> <span class="identifier">cdf</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">dist</span><span class="special">,</span> <span class="number">1.0</span><span class="special">))</span> <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
But wait, now that we have a complement, we have to be able to use it as
|
||||
well. Any function that accepts a probability as an argument can also accept
|
||||
a complement by wrapping all of its arguments in a call to <code class="computeroutput"><span class="identifier">complement</span><span class="special">(...)</span></code>,
|
||||
for example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">students_t</span> <span class="identifier">dist</span><span class="special">(</span><span class="number">5</span><span class="special">);</span>
|
||||
|
||||
<span class="keyword">for</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">1e10</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">*=</span> <span class="number">10</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="comment">// Calculate the quantile for a 1 in i chance:</span>
|
||||
<span class="keyword">double</span> <span class="identifier">t</span> <span class="special">=</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">dist</span><span class="special">,</span> <span class="number">1</span><span class="special">/</span><span class="identifier">i</span><span class="special">));</span>
|
||||
<span class="comment">// Print it out:</span>
|
||||
<span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Quantile of students-t with 5 degrees of freedom\n"</span>
|
||||
<span class="string">"for a 1 in "</span> <span class="special"><<</span> <span class="identifier">i</span> <span class="special"><<</span> <span class="string">" chance is "</span> <span class="special"><<</span> <span class="identifier">t</span> <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<div class="tip"><table border="0" summary="Tip">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../../doc/src/images/tip.png"></td>
|
||||
<th align="left">Tip</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
<span class="bold"><strong>Critical values are just quantiles</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
Some texts talk about quantiles, or percentiles or fractiles, others
|
||||
about critical values, the basic rule is:
|
||||
</p>
|
||||
<p>
|
||||
<span class="emphasis"><em>Lower critical values</em></span> are the same as the quantile.
|
||||
</p>
|
||||
<p>
|
||||
<span class="emphasis"><em>Upper critical values</em></span> are the same as the quantile
|
||||
from the complement of the probability.
|
||||
</p>
|
||||
<p>
|
||||
For example, suppose we have a Bernoulli process, giving rise to a binomial
|
||||
distribution with success ratio 0.1 and 100 trials in total. The <span class="emphasis"><em>lower
|
||||
critical value</em></span> for a probability of 0.05 is given by:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">binomial</span><span class="special">(</span><span class="number">100</span><span class="special">,</span> <span class="number">0.1</span><span class="special">),</span> <span class="number">0.05</span><span class="special">)</span></code>
|
||||
</p>
|
||||
<p>
|
||||
and the <span class="emphasis"><em>upper critical value</em></span> is given by:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">binomial</span><span class="special">(</span><span class="number">100</span><span class="special">,</span> <span class="number">0.1</span><span class="special">),</span> <span class="number">0.05</span><span class="special">))</span></code>
|
||||
</p>
|
||||
<p>
|
||||
which return 4.82 and 14.63 respectively.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<a name="why_complements"></a><div class="tip"><table border="0" summary="Tip">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../../doc/src/images/tip.png"></td>
|
||||
<th align="left">Tip</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
<span class="bold"><strong>Why bother with complements anyway?</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
It's very tempting to dispense with complements, and simply subtract
|
||||
the probability from 1 when required. However, consider what happens
|
||||
when the probability is very close to 1: let's say the probability expressed
|
||||
at float precision is <code class="computeroutput"><span class="number">0.999999940f</span></code>,
|
||||
then <code class="computeroutput"><span class="number">1</span> <span class="special">-</span>
|
||||
<span class="number">0.999999940f</span> <span class="special">=</span>
|
||||
<span class="number">5.96046448e-008</span></code>, but the result
|
||||
is actually accurate to just <span class="emphasis"><em>one single bit</em></span>: the
|
||||
only bit that didn't cancel out!
|
||||
</p>
|
||||
<p>
|
||||
Or to look at this another way: consider that we want the risk of falsely
|
||||
rejecting the null-hypothesis in the Student's t test to be 1 in 1 billion,
|
||||
for a sample size of 10,000. This gives a probability of 1 - 10<sup>-9</sup>, which
|
||||
is exactly 1 when calculated at float precision. In this case calculating
|
||||
the quantile from the complement neatly solves the problem, so for example:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">students_t</span><span class="special">(</span><span class="number">10000</span><span class="special">),</span> <span class="number">1e-9</span><span class="special">))</span></code>
|
||||
</p>
|
||||
<p>
|
||||
returns the expected t-statistic <code class="computeroutput"><span class="number">6.00336</span></code>,
|
||||
where as:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">students_t</span><span class="special">(</span><span class="number">10000</span><span class="special">),</span> <span class="number">1</span><span class="special">-</span><span class="number">1e-9f</span><span class="special">)</span></code>
|
||||
</p>
|
||||
<p>
|
||||
raises an overflow error, since it is the same as:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">students_t</span><span class="special">(</span><span class="number">10000</span><span class="special">),</span> <span class="number">1</span><span class="special">)</span></code>
|
||||
</p>
|
||||
<p>
|
||||
Which has no finite result.
|
||||
</p>
|
||||
<p>
|
||||
With all distributions, even for more reasonable probability (unless
|
||||
the value of p can be represented exactly in the floating-point type)
|
||||
the loss of accuracy quickly becomes significant if you simply calculate
|
||||
probability from 1 - p (because it will be mostly garbage digits for
|
||||
p ~ 1).
|
||||
</p>
|
||||
<p>
|
||||
So always avoid, for example, using a probability near to unity like
|
||||
0.99999
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">my_distribution</span><span class="special">,</span>
|
||||
<span class="number">0.99999</span><span class="special">)</span></code>
|
||||
</p>
|
||||
<p>
|
||||
and instead use
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">complement</span><span class="special">(</span><span class="identifier">my_distribution</span><span class="special">,</span>
|
||||
<span class="number">0.00001</span><span class="special">))</span></code>
|
||||
</p>
|
||||
<p>
|
||||
since 1 - 0.99999 is not exactly equal to 0.00001 when using floating-point
|
||||
arithmetic.
|
||||
</p>
|
||||
<p>
|
||||
This assumes that the 0.00001 value is either a constant, or can be computed
|
||||
by some manner other than subtracting 0.99999 from 1.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="generic.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="parameters.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,254 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Generic operations common to all distributions are non-member functions</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../overview.html" title="Overview of Distributions">
|
||||
<link rel="prev" href="objects.html" title="Distributions are Objects">
|
||||
<link rel="next" href="complements.html" title="Complements are supported too - and when to use them">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="objects.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="complements.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.stat_tut.overview.generic"></a><a class="link" href="generic.html" title="Generic operations common to all distributions are non-member functions">Generic operations
|
||||
common to all distributions are non-member functions</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Want to calculate the PDF (Probability Density Function) of a distribution?
|
||||
No problem, just use:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">pdf</span><span class="special">(</span><span class="identifier">my_dist</span><span class="special">,</span> <span class="identifier">x</span><span class="special">);</span> <span class="comment">// Returns PDF (density) at point x of distribution my_dist.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Or how about the CDF (Cumulative Distribution Function):
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">my_dist</span><span class="special">,</span> <span class="identifier">x</span><span class="special">);</span> <span class="comment">// Returns CDF (integral from -infinity to point x)</span>
|
||||
<span class="comment">// of distribution my_dist.</span>
|
||||
</pre>
|
||||
<p>
|
||||
And quantiles are just the same:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">quantile</span><span class="special">(</span><span class="identifier">my_dist</span><span class="special">,</span> <span class="identifier">p</span><span class="special">);</span> <span class="comment">// Returns the value of the random variable x</span>
|
||||
<span class="comment">// such that cdf(my_dist, x) == p.</span>
|
||||
</pre>
|
||||
<p>
|
||||
If you're wondering why these aren't member functions, it's to make the
|
||||
library more easily extensible: if you want to add additional generic operations
|
||||
- let's say the <span class="emphasis"><em>n'th moment</em></span> - then all you have to
|
||||
do is add the appropriate non-member functions, overloaded for each implemented
|
||||
distribution type.
|
||||
</p>
|
||||
<div class="tip"><table border="0" summary="Tip">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../../doc/src/images/tip.png"></td>
|
||||
<th align="left">Tip</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
<span class="bold"><strong>Random numbers that approximate Quantiles of Distributions</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
If you want random numbers that are distributed in a specific way, for
|
||||
example in a uniform, normal or triangular, see <a href="http://www.boost.org/libs/random/" target="_top">Boost.Random</a>.
|
||||
</p>
|
||||
<p>
|
||||
Whilst in principal there's nothing to prevent you from using the quantile
|
||||
function to convert a uniformly distributed random number to another
|
||||
distribution, in practice there are much more efficient algorithms available
|
||||
that are specific to random number generation.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
For example, the binomial distribution has two parameters: n (the number
|
||||
of trials) and p (the probability of success on any one trial).
|
||||
</p>
|
||||
<p>
|
||||
The <code class="computeroutput"><span class="identifier">binomial_distribution</span></code>
|
||||
constructor therefore has two parameters:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">binomial_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">RealType</span>
|
||||
<span class="identifier">p</span><span class="special">);</span></code>
|
||||
</p>
|
||||
<p>
|
||||
For this distribution the <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random
|
||||
variate</a> is k: the number of successes observed. The probability
|
||||
density/mass function (pdf) is therefore written as <span class="emphasis"><em>f(k; n, p)</em></span>.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
<span class="bold"><strong>Random Variates and Distribution Parameters</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
The concept of a <a href="http://en.wikipedia.org/wiki/Random_variable" target="_top">random
|
||||
variable</a> is closely linked to the term <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random
|
||||
variate</a>: a random variate is a particular value (outcome) of
|
||||
a random variable. and <a href="http://en.wikipedia.org/wiki/Parameter" target="_top">distribution
|
||||
parameters</a> are conventionally distinguished (for example in Wikipedia
|
||||
and Wolfram MathWorld) by placing a semi-colon or vertical bar) <span class="emphasis"><em>after</em></span>
|
||||
the <a href="http://en.wikipedia.org/wiki/Random_variable" target="_top">random
|
||||
variable</a> (whose value you 'choose'), to separate the variate
|
||||
from the parameter(s) that defines the shape of the distribution.<br>
|
||||
For example, the binomial distribution probability distribution function
|
||||
(PDF) is written as <span class="emphasis"><em>f(k| n, p)</em></span> = Pr(K = k|n, p)
|
||||
= probability of observing k successes out of n trials. K is the <a href="http://en.wikipedia.org/wiki/Random_variable" target="_top">random variable</a>,
|
||||
k is the <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random
|
||||
variate</a>, the parameters are n (trials) and p (probability).
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
By convention, <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random
|
||||
variate</a> are lower case, usually k is integral, x if real, and
|
||||
<a href="http://en.wikipedia.org/wiki/Random_variable" target="_top">random variable</a>
|
||||
are upper case, K if integral, X if real. But this implementation treats
|
||||
all as floating point values <code class="computeroutput"><span class="identifier">RealType</span></code>,
|
||||
so if you really want an integral result, you must round: see note on
|
||||
Discrete Probability Distributions below for details.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
As noted above the non-member function <code class="computeroutput"><span class="identifier">pdf</span></code>
|
||||
has one parameter for the distribution object, and a second for the random
|
||||
variate. So taking our binomial distribution example, we would write:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">pdf</span><span class="special">(</span><span class="identifier">binomial_distribution</span><span class="special"><</span><span class="identifier">RealType</span><span class="special">>(</span><span class="identifier">n</span><span class="special">,</span> <span class="identifier">p</span><span class="special">),</span> <span class="identifier">k</span><span class="special">);</span></code>
|
||||
</p>
|
||||
<p>
|
||||
The ranges of <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random
|
||||
variate</a> values that are permitted and are supported can be tested
|
||||
by using two functions <code class="computeroutput"><span class="identifier">range</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">support</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
The distribution (effectively the <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random
|
||||
variate</a>) is said to be 'supported' over a range that is <a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">"the smallest
|
||||
closed set whose complement has probability zero"</a>. MathWorld
|
||||
uses the word 'defined' for this range. Non-mathematicians might say it
|
||||
means the 'interesting' smallest range of random variate x that has the
|
||||
cdf going from zero to unity. Outside are uninteresting zones where the
|
||||
pdf is zero, and the cdf zero or unity.
|
||||
</p>
|
||||
<p>
|
||||
For most distributions, with probability distribution functions one might
|
||||
describe as 'well-behaved', we have decided that it is most useful for
|
||||
the supported range to <span class="bold"><strong>exclude</strong></span> random
|
||||
variate values like exact zero <span class="bold"><strong>if the end point is
|
||||
discontinuous</strong></span>. For example, the Weibull (scale 1, shape 1) distribution
|
||||
smoothly heads for unity as the random variate x declines towards zero.
|
||||
But at x = zero, the value of the pdf is suddenly exactly zero, by definition.
|
||||
If you are plotting the PDF, or otherwise calculating, zero is not the
|
||||
most useful value for the lower limit of supported, as we discovered. So
|
||||
for this, and similar distributions, we have decided it is most numerically
|
||||
useful to use the closest value to zero, min_value, for the limit of the
|
||||
supported range. (The <code class="computeroutput"><span class="identifier">range</span></code>
|
||||
remains from zero, so you will still get <code class="computeroutput"><span class="identifier">pdf</span><span class="special">(</span><span class="identifier">weibull</span><span class="special">,</span> <span class="number">0</span><span class="special">)</span>
|
||||
<span class="special">==</span> <span class="number">0</span></code>).
|
||||
(Exponential and gamma distributions have similarly discontinuous functions).
|
||||
</p>
|
||||
<p>
|
||||
Mathematically, the functions may make sense with an (+ or -) infinite
|
||||
value, but except for a few special cases (in the Normal and Cauchy distributions)
|
||||
this implementation limits random variates to finite values from the <code class="computeroutput"><span class="identifier">max</span></code> to <code class="computeroutput"><span class="identifier">min</span></code>
|
||||
for the <code class="computeroutput"><span class="identifier">RealType</span></code>. (See
|
||||
<a class="link" href="../../sf_implementation.html#math_toolkit.sf_implementation.handling_of_floating_point_infin">Handling
|
||||
of Floating-Point Infinity</a> for rationale).
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top">
|
||||
<p>
|
||||
<span class="bold"><strong>Discrete Probability Distributions</strong></span>
|
||||
</p>
|
||||
<p>
|
||||
Note that the <a href="http://en.wikipedia.org/wiki/Discrete_probability_distribution" target="_top">discrete
|
||||
distributions</a>, including the binomial, negative binomial, Poisson
|
||||
& Bernoulli, are all mathematically defined as discrete functions:
|
||||
that is to say the functions <code class="computeroutput"><span class="identifier">cdf</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">pdf</span></code> are only defined
|
||||
for integral values of the random variate.
|
||||
</p>
|
||||
<p>
|
||||
However, because the method of calculation often uses continuous functions
|
||||
it is convenient to treat them as if they were continuous functions,
|
||||
and permit non-integral values of their parameters.
|
||||
</p>
|
||||
<p>
|
||||
Users wanting to enforce a strict mathematical model may use <code class="computeroutput"><span class="identifier">floor</span></code> or <code class="computeroutput"><span class="identifier">ceil</span></code>
|
||||
functions on the random variate prior to calling the distribution function.
|
||||
</p>
|
||||
<p>
|
||||
The quantile functions for these distributions are hard to specify in
|
||||
a manner that will satisfy everyone all of the time. The default behaviour
|
||||
is to return an integer result, that has been rounded <span class="emphasis"><em>outwards</em></span>:
|
||||
that is to say, lower quantiles - where the probablity is less than 0.5
|
||||
are rounded down, while upper quantiles - where the probability is greater
|
||||
than 0.5 - are rounded up. This behaviour ensures that if an X% quantile
|
||||
is requested, then <span class="emphasis"><em>at least</em></span> the requested coverage
|
||||
will be present in the central region, and <span class="emphasis"><em>no more than</em></span>
|
||||
the requested coverage will be present in the tails.
|
||||
</p>
|
||||
<p>
|
||||
This behaviour can be changed so that the quantile functions are rounded
|
||||
differently, or return a real-valued result using <a class="link" href="../../pol_overview.html" title="Policy Overview">Policies</a>.
|
||||
It is strongly recommended that you read the tutorial <a class="link" href="../../pol_tutorial/understand_dis_quant.html" title="Understanding Quantiles of Discrete Distributions">Understanding
|
||||
Quantiles of Discrete Distributions</a> before using the quantile
|
||||
function on a discrete distribtion. The <a class="link" href="../../pol_ref/discrete_quant_ref.html" title="Discrete Quantile Policies">reference
|
||||
docs</a> describe how to change the rounding policy for these distributions.
|
||||
</p>
|
||||
<p>
|
||||
For similar reasons continuous distributions with parameters like "degrees
|
||||
of freedom" that might appear to be integral, are treated as real
|
||||
values (and are promoted from integer to floating-point if necessary).
|
||||
In this case however, there are a small number of situations where non-integral
|
||||
degrees of freedom do have a genuine meaning.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="objects.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="complements.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,78 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Headers and Namespaces</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../overview.html" title="Overview of Distributions">
|
||||
<link rel="prev" href="../overview.html" title="Overview of Distributions">
|
||||
<link rel="next" href="objects.html" title="Distributions are Objects">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../overview.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="objects.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.stat_tut.overview.headers"></a><a class="link" href="headers.html" title="Headers and Namespaces">Headers and
|
||||
Namespaces</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
All the code in this library is inside namespace boost::math.
|
||||
</p>
|
||||
<p>
|
||||
In order to use a distribution <span class="emphasis"><em>my_distribution</em></span> you
|
||||
will need to include either the header <boost/math/my_distribution.hpp>
|
||||
or the "include all the distributions" header: <boost/math/distributions.hpp>.
|
||||
</p>
|
||||
<p>
|
||||
For example, to use the Students-t distribution include either <boost/math/students_t.hpp>
|
||||
or <boost/math/distributions.hpp>
|
||||
</p>
|
||||
<p>
|
||||
You also need to bring distribution names into scope, perhaps with a <code class="computeroutput"><span class="keyword">using</span> <span class="keyword">namespace</span>
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">;</span></code>
|
||||
declaration,
|
||||
</p>
|
||||
<p>
|
||||
or specific <code class="computeroutput"><span class="keyword">using</span></code> declarations
|
||||
like <code class="computeroutput"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">normal</span><span class="special">;</span></code> (<span class="bold"><strong>recommended</strong></span>).
|
||||
</p>
|
||||
<div class="caution"><table border="0" summary="Caution">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../doc/src/images/caution.png"></td>
|
||||
<th align="left">Caution</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
Some math function names are also used in namespace std so including
|
||||
<random> could cause ambiguity!
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../overview.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="objects.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,134 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Distributions are Objects</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../overview.html" title="Overview of Distributions">
|
||||
<link rel="prev" href="headers.html" title="Headers and Namespaces">
|
||||
<link rel="next" href="generic.html" title="Generic operations common to all distributions are non-member functions">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="headers.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="generic.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.stat_tut.overview.objects"></a><a class="link" href="objects.html" title="Distributions are Objects">Distributions
|
||||
are Objects</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Each kind of distribution in this library is a class type - an object.
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policies</a> provide fine-grained control of
|
||||
the behaviour of these classes, allowing the user to customise behaviour
|
||||
such as how errors are handled, or how the quantiles of discrete distribtions
|
||||
behave.
|
||||
</p>
|
||||
<div class="tip"><table border="0" summary="Tip">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../../doc/src/images/tip.png"></td>
|
||||
<th align="left">Tip</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
If you are familiar with statistics libraries using functions, and 'Distributions
|
||||
as Objects' seem alien, see <a class="link" href="../weg/nag_library.html" title="Comparison with C, R, FORTRAN-style Free Functions">the
|
||||
comparison to other statistics libraries.</a>
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
Making distributions class types does two things:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
It encapsulates the kind of distribution in the C++ type system; so,
|
||||
for example, Students-t distributions are always a different C++ type
|
||||
from Chi-Squared distributions.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
The distribution objects store any parameters associated with the distribution:
|
||||
for example, the Students-t distribution has a <span class="emphasis"><em>degrees of
|
||||
freedom</em></span> parameter that controls the shape of the distribution.
|
||||
This <span class="emphasis"><em>degrees of freedom</em></span> parameter has to be provided
|
||||
to the Students-t object when it is constructed.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
Although the distribution classes in this library are templates, there
|
||||
are typedefs on type <span class="emphasis"><em>double</em></span> that mostly take the usual
|
||||
name of the distribution (except where there is a clash with a function
|
||||
of the same name: beta and gamma, in which case using the default template
|
||||
arguments - <code class="computeroutput"><span class="identifier">RealType</span> <span class="special">=</span>
|
||||
<span class="keyword">double</span></code> - is nearly as convenient).
|
||||
Probably 95% of uses are covered by these typedefs:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="comment">// using namespace boost::math; // Avoid potential ambiguity with names in std <random></span>
|
||||
<span class="comment">// Safer to declare specific functions with using statement(s):</span>
|
||||
|
||||
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">beta_distribution</span><span class="special">;</span>
|
||||
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">binomial_distribution</span><span class="special">;</span>
|
||||
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">students_t</span><span class="special">;</span>
|
||||
|
||||
<span class="comment">// Construct a students_t distribution with 4 degrees of freedom:</span>
|
||||
<span class="identifier">students_t</span> <span class="identifier">d1</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Construct a double-precision beta distribution</span>
|
||||
<span class="comment">// with parameters a = 10, b = 20</span>
|
||||
<span class="identifier">beta_distribution</span><span class="special"><></span> <span class="identifier">d2</span><span class="special">(</span><span class="number">10</span><span class="special">,</span> <span class="number">20</span><span class="special">);</span> <span class="comment">// Note: _distribution<> suffix !</span>
|
||||
</pre>
|
||||
<p>
|
||||
If you need to use the distributions with a type other than <code class="computeroutput"><span class="keyword">double</span></code>, then you can instantiate the template
|
||||
directly: the names of the templates are the same as the <code class="computeroutput"><span class="keyword">double</span></code> typedef but with <code class="computeroutput"><span class="identifier">_distribution</span></code>
|
||||
appended, for example: <a class="link" href="../../dist_ref/dists/students_t_dist.html" title="Students t Distribution">Students
|
||||
t Distribution</a> or <a class="link" href="../../dist_ref/dists/binomial_dist.html" title="Binomial Distribution">Binomial
|
||||
Distribution</a>:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="comment">// Construct a students_t distribution, of float type,</span>
|
||||
<span class="comment">// with 4 degrees of freedom:</span>
|
||||
<span class="identifier">students_t_distribution</span><span class="special"><</span><span class="keyword">float</span><span class="special">></span> <span class="identifier">d3</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>
|
||||
|
||||
<span class="comment">// Construct a binomial distribution, of long double type,</span>
|
||||
<span class="comment">// with probability of success 0.3</span>
|
||||
<span class="comment">// and 20 trials in total:</span>
|
||||
<span class="identifier">binomial_distribution</span><span class="special"><</span><span class="keyword">long</span> <span class="keyword">double</span><span class="special">></span> <span class="identifier">d4</span><span class="special">(</span><span class="number">20</span><span class="special">,</span> <span class="number">0.3</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
The parameters passed to the distributions can be accessed via getter member
|
||||
functions:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">d1</span><span class="special">.</span><span class="identifier">degrees_of_freedom</span><span class="special">();</span> <span class="comment">// returns 4.0</span>
|
||||
</pre>
|
||||
<p>
|
||||
This is all well and good, but not very useful so far. What we often want
|
||||
is to be able to calculate the <span class="emphasis"><em>cumulative distribution functions</em></span>
|
||||
and <span class="emphasis"><em>quantiles</em></span> etc for these distributions.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="headers.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="generic.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,73 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Parameters can be calculated</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../overview.html" title="Overview of Distributions">
|
||||
<link rel="prev" href="complements.html" title="Complements are supported too - and when to use them">
|
||||
<link rel="next" href="summary.html" title="Summary">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="complements.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="summary.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.stat_tut.overview.parameters"></a><a class="link" href="parameters.html" title="Parameters can be calculated">Parameters
|
||||
can be calculated</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Sometimes it's the parameters that define the distribution that you need
|
||||
to find. Suppose, for example, you have conducted a Students-t test for
|
||||
equal means and the result is borderline. Maybe your two samples differ
|
||||
from each other, or maybe they don't; based on the result of the test you
|
||||
can't be sure. A legitimate question to ask then is "How many more
|
||||
measurements would I have to take before I would get an X% probability
|
||||
that the difference is real?" Parameter finders can answer questions
|
||||
like this, and are necessarily different for each distribution. They are
|
||||
implemented as static member functions of the distributions, for example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">students_t</span><span class="special">::</span><span class="identifier">find_degrees_of_freedom</span><span class="special">(</span>
|
||||
<span class="number">1.3</span><span class="special">,</span> <span class="comment">// difference from true mean to detect</span>
|
||||
<span class="number">0.05</span><span class="special">,</span> <span class="comment">// maximum risk of falsely rejecting the null-hypothesis.</span>
|
||||
<span class="number">0.1</span><span class="special">,</span> <span class="comment">// maximum risk of falsely failing to reject the null-hypothesis.</span>
|
||||
<span class="number">0.13</span><span class="special">);</span> <span class="comment">// sample standard deviation</span>
|
||||
</pre>
|
||||
<p>
|
||||
Returns the number of degrees of freedom required to obtain a 95% probability
|
||||
that the observed differences in means is not down to chance alone. In
|
||||
the case that a borderline Students-t test result was previously obtained,
|
||||
this can be used to estimate how large the sample size would have to become
|
||||
before the observed difference was considered significant. It assumes,
|
||||
of course, that the sample mean and standard deviation are invariant with
|
||||
sample size.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="complements.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="summary.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,75 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Summary</title>
|
||||
<link rel="stylesheet" href="../../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../overview.html" title="Overview of Distributions">
|
||||
<link rel="prev" href="parameters.html" title="Parameters can be calculated">
|
||||
<link rel="next" href="../weg.html" title="Worked Examples">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="parameters.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="../weg.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="math_toolkit.stat_tut.overview.summary"></a><a class="link" href="summary.html" title="Summary">Summary</a>
|
||||
</h4></div></div></div>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
Distributions are objects, which are constructed from whatever parameters
|
||||
the distribution may have.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Member functions allow you to retrieve the parameters of a distribution.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Generic non-member functions provide access to the properties that
|
||||
are common to all the distributions (PDF, CDF, quantile etc).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Complements of probabilities are calculated by wrapping the function's
|
||||
arguments in a call to <code class="computeroutput"><span class="identifier">complement</span><span class="special">(...)</span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Functions that accept a probability can accept a complement of the
|
||||
probability as well, by wrapping the function's arguments in a call
|
||||
to <code class="computeroutput"><span class="identifier">complement</span><span class="special">(...)</span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Static member functions allow the parameters of a distribution to be
|
||||
found from other information.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
Now that you have the basics, the next section looks at some worked examples.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="parameters.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="../weg.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user