3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Poisson 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="pareto.html" title="Pareto Distribution">
10 <link rel="next" href="rayleigh.html" title="Rayleigh 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="pareto.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="rayleigh.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.poisson_dist"></a><a class="link" href="poisson_dist.html" title="Poisson Distribution">Poisson 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">poisson</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">poisson_distribution</span><span class="special">;</span>
36 <span class="keyword">typedef</span> <span class="identifier">poisson_distribution</span><span class="special"><></span> <span class="identifier">poisson</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">poisson_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>
43 <span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span>
45 <span class="identifier">poisson_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">mean</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span> <span class="comment">// Constructor.</span>
46 <span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// Accessor.</span>
47 <span class="special">}</span>
49 <span class="special">}}</span> <span class="comment">// namespaces boost::math</span>
52 The <a href="http://en.wikipedia.org/wiki/Poisson_distribution" target="_top">Poisson
53 distribution</a> is a well-known statistical discrete distribution.
54 It expresses the probability of a number of events (or failures, arrivals,
55 occurrences ...) occurring in a fixed period of time, provided these events
56 occur with a known mean rate λ
57 (events/time), and are independent of the
58 time since the last event.
61 The distribution was discovered by Siméon-Denis Poisson (1781 to 1840).
64 It has the Probability Mass Function:
66 <div class="blockquote"><blockquote class="blockquote"><p>
67 <span class="inlinemediaobject"><img src="../../../../equations/poisson_ref1.svg"></span>
69 </p></blockquote></div>
71 for k events, with an expected number of events λ.
74 The following graph illustrates how the PDF varies with the parameter λ:
76 <div class="blockquote"><blockquote class="blockquote"><p>
77 <span class="inlinemediaobject"><img src="../../../../graphs/poisson_pdf_1.svg" align="middle"></span>
79 </p></blockquote></div>
80 <div class="caution"><table border="0" summary="Caution">
82 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../doc/src/images/caution.png"></td>
83 <th align="left">Caution</th>
85 <tr><td align="left" valign="top">
87 The Poisson distribution is a discrete distribution: internally, functions
88 like the <code class="computeroutput"><span class="identifier">cdf</span></code> and <code class="computeroutput"><span class="identifier">pdf</span></code> are treated "as if" they
89 are continuous functions, but in reality the results returned from these
90 functions only have meaning if an integer value is provided for the random
94 The quantile function will by default return an integer result that has
95 been <span class="emphasis"><em>rounded outwards</em></span>. That is to say lower quantiles
96 (where the probability is less than 0.5) are rounded downward, and upper
97 quantiles (where the probability is greater than 0.5) are rounded upwards.
98 This behaviour ensures that if an X% quantile is requested, then <span class="emphasis"><em>at
99 least</em></span> the requested coverage will be present in the central
100 region, and <span class="emphasis"><em>no more than</em></span> the requested coverage
101 will be present in the tails.
104 This behaviour can be changed so that the quantile functions are rounded
105 differently, or even return a real-valued result using <a class="link" href="../../pol_overview.html" title="Policy Overview">Policies</a>.
106 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
107 Quantiles of Discrete Distributions</a> before using the quantile
108 function on the Poisson distribution. The <a class="link" href="../../pol_ref/discrete_quant_ref.html" title="Discrete Quantile Policies">reference
109 docs</a> describe how to change the rounding policy for these distributions.
114 <a name="math_toolkit.dist_ref.dists.poisson_dist.h0"></a>
115 <span class="phrase"><a name="math_toolkit.dist_ref.dists.poisson_dist.member_functions"></a></span><a class="link" href="poisson_dist.html#math_toolkit.dist_ref.dists.poisson_dist.member_functions">Member
118 <pre class="programlisting"><span class="identifier">poisson_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">mean</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
121 Constructs a poisson distribution with mean <span class="emphasis"><em>mean</em></span>.
123 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
126 Returns the <span class="emphasis"><em>mean</em></span> of this distribution.
129 <a name="math_toolkit.dist_ref.dists.poisson_dist.h1"></a>
130 <span class="phrase"><a name="math_toolkit.dist_ref.dists.poisson_dist.non_member_accessors"></a></span><a class="link" href="poisson_dist.html#math_toolkit.dist_ref.dists.poisson_dist.non_member_accessors">Non-member
134 All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
135 functions</a> that are generic to all distributions are supported:
136 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
137 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
138 <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>,
139 <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>,
140 <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>,
141 <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
142 <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>,
143 <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>.
146 The domain of the random variable is [0, ∞].
149 <a name="math_toolkit.dist_ref.dists.poisson_dist.h2"></a>
150 <span class="phrase"><a name="math_toolkit.dist_ref.dists.poisson_dist.accuracy"></a></span><a class="link" href="poisson_dist.html#math_toolkit.dist_ref.dists.poisson_dist.accuracy">Accuracy</a>
153 The Poisson distribution is implemented in terms of the incomplete gamma
154 functions <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a> and
155 <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a> and as such
156 should have low error rates: but refer to the documentation of those functions
157 for more information. The quantile and its complement use the inverse gamma
158 functions and are therefore probably slightly less accurate: this is because
159 the inverse gamma functions are implemented using an iterative method with
160 a lower tolerance to avoid excessive computation.
163 <a name="math_toolkit.dist_ref.dists.poisson_dist.h3"></a>
164 <span class="phrase"><a name="math_toolkit.dist_ref.dists.poisson_dist.implementation"></a></span><a class="link" href="poisson_dist.html#math_toolkit.dist_ref.dists.poisson_dist.implementation">Implementation</a>
167 In the following table λ is the mean of the distribution, <span class="emphasis"><em>k</em></span>
168 is the random variable, <span class="emphasis"><em>p</em></span> is the probability and
169 <span class="emphasis"><em>q = 1-p</em></span>.
171 <div class="informaltable"><table class="table">
197 Using the relation: pdf = e<sup>-λ</sup> λ<sup>k</sup> / k!
209 Using the relation: p = Γ(k+1, λ) / k! = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_q</a>(k+1,
222 Using the relation: q = <a class="link" href="../../sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p</a>(k+1,
235 Using the relation: k = <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_q_inva</a>(λ,
243 quantile from the complement
248 Using the relation: k = <a class="link" href="../../sf_gamma/igamma_inv.html" title="Incomplete Gamma Function Inverses">gamma_p_inva</a>(λ,
273 floor (λ) or ⌊λ⌋
316 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
317 <td align="left"></td>
318 <td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar
319 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
320 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
321 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
322 Daryle Walker and Xiaogang Zhang<p>
323 Distributed under the Boost Software License, Version 1.0. (See accompanying
324 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>)
329 <div class="spirit-nav">
330 <a accesskey="p" href="pareto.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="rayleigh.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>