]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>Exponential 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="chi_squared_dist.html" title="Chi Squared Distribution"> | |
10 | <link rel="next" href="extreme_dist.html" title="Extreme Value Distribution"> | |
11 | </head> | |
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> | |
20 | </tr></table> | |
21 | <hr> | |
22 | <div class="spirit-nav"> | |
23 | <a accesskey="p" href="chi_squared_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="extreme_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> | |
24 | </div> | |
25 | <div class="section"> | |
26 | <div class="titlepage"><div><div><h4 class="title"> | |
27 | <a name="math_toolkit.dist_ref.dists.exp_dist"></a><a class="link" href="exp_dist.html" title="Exponential Distribution">Exponential 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">exponential</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></pre> | |
30 | <pre class="programlisting"><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> | |
31 | <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> | |
32 | <span class="keyword">class</span> <span class="identifier">exponential_distribution</span><span class="special">;</span> | |
33 | ||
34 | <span class="keyword">typedef</span> <span class="identifier">exponential_distribution</span><span class="special"><></span> <span class="identifier">exponential</span><span class="special">;</span> | |
35 | ||
36 | <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> | |
37 | <span class="keyword">class</span> <span class="identifier">exponential_distribution</span> | |
38 | <span class="special">{</span> | |
39 | <span class="keyword">public</span><span class="special">:</span> | |
40 | <span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span> | |
41 | <span class="keyword">typedef</span> <span class="identifier">Policy</span> <span class="identifier">policy_type</span><span class="special">;</span> | |
42 | ||
43 | <span class="identifier">exponential_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lambda</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span> | |
44 | ||
45 | <span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> | |
46 | <span class="special">};</span> | |
47 | </pre> | |
48 | <p> | |
49 | The <a href="http://en.wikipedia.org/wiki/Exponential_distribution" target="_top">exponential | |
50 | distribution</a> is a <a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">continuous | |
51 | probability distribution</a> with PDF: | |
52 | </p> | |
53 | <p> | |
54 | <span class="inlinemediaobject"><img src="../../../../equations/exponential_dist_ref1.svg"></span> | |
55 | </p> | |
56 | <p> | |
57 | It is often used to model the time between independent events that happen | |
58 | at a constant average rate. | |
59 | </p> | |
60 | <p> | |
61 | The following graph shows how the distribution changes for different values | |
62 | of the rate parameter lambda: | |
63 | </p> | |
64 | <p> | |
65 | <span class="inlinemediaobject"><img src="../../../../graphs/exponential_pdf.svg" align="middle"></span> | |
66 | </p> | |
67 | <h5> | |
68 | <a name="math_toolkit.dist_ref.dists.exp_dist.h0"></a> | |
69 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.exp_dist.member_functions"></a></span><a class="link" href="exp_dist.html#math_toolkit.dist_ref.dists.exp_dist.member_functions">Member | |
70 | Functions</a> | |
71 | </h5> | |
72 | <pre class="programlisting"><span class="identifier">exponential_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">lambda</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span> | |
73 | </pre> | |
74 | <p> | |
75 | Constructs an <a href="http://en.wikipedia.org/wiki/Exponential_distribution" target="_top">Exponential | |
76 | distribution</a> with parameter <span class="emphasis"><em>lambda</em></span>. Lambda | |
77 | is defined as the reciprocal of the scale parameter. | |
78 | </p> | |
79 | <p> | |
80 | Requires lambda > 0, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>. | |
81 | </p> | |
82 | <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">lambda</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> | |
83 | </pre> | |
84 | <p> | |
85 | Accessor function returns the lambda parameter of the distribution. | |
86 | </p> | |
87 | <h5> | |
88 | <a name="math_toolkit.dist_ref.dists.exp_dist.h1"></a> | |
89 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.exp_dist.non_member_accessors"></a></span><a class="link" href="exp_dist.html#math_toolkit.dist_ref.dists.exp_dist.non_member_accessors">Non-member | |
90 | Accessors</a> | |
91 | </h5> | |
92 | <p> | |
93 | All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor | |
94 | functions</a> that are generic to all distributions are supported: | |
95 | <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>, | |
96 | <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>, | |
97 | <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>, | |
98 | <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>, | |
99 | <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>, | |
100 | <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>, | |
101 | <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>, | |
102 | <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>. | |
103 | </p> | |
104 | <p> | |
105 | The domain of the random variable is [0, +∞]. | |
106 | </p> | |
107 | <h5> | |
108 | <a name="math_toolkit.dist_ref.dists.exp_dist.h2"></a> | |
109 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.exp_dist.accuracy"></a></span><a class="link" href="exp_dist.html#math_toolkit.dist_ref.dists.exp_dist.accuracy">Accuracy</a> | |
110 | </h5> | |
111 | <p> | |
112 | The exponential distribution is implemented in terms of the standard library | |
113 | functions <code class="computeroutput"><span class="identifier">exp</span></code>, <code class="computeroutput"><span class="identifier">log</span></code>, <code class="computeroutput"><span class="identifier">log1p</span></code> | |
114 | and <code class="computeroutput"><span class="identifier">expm1</span></code> and as such should | |
115 | have very low error rates. | |
116 | </p> | |
117 | <h5> | |
118 | <a name="math_toolkit.dist_ref.dists.exp_dist.h3"></a> | |
119 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.exp_dist.implementation"></a></span><a class="link" href="exp_dist.html#math_toolkit.dist_ref.dists.exp_dist.implementation">Implementation</a> | |
120 | </h5> | |
121 | <p> | |
122 | In the following table λ is the parameter lambda of the distribution, <span class="emphasis"><em>x</em></span> | |
123 | is the random variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q | |
124 | = 1-p</em></span>. | |
125 | </p> | |
126 | <div class="informaltable"><table class="table"> | |
127 | <colgroup> | |
128 | <col> | |
129 | <col> | |
130 | </colgroup> | |
131 | <thead><tr> | |
132 | <th> | |
133 | <p> | |
134 | Function | |
135 | </p> | |
136 | </th> | |
137 | <th> | |
138 | <p> | |
139 | Implementation Notes | |
140 | </p> | |
141 | </th> | |
142 | </tr></thead> | |
143 | <tbody> | |
144 | <tr> | |
145 | <td> | |
146 | <p> | |
147 | ||
148 | </p> | |
149 | </td> | |
150 | <td> | |
151 | <p> | |
152 | Using the relation: pdf = λ * exp(-λ * x) | |
153 | </p> | |
154 | </td> | |
155 | </tr> | |
156 | <tr> | |
157 | <td> | |
158 | <p> | |
159 | cdf | |
160 | </p> | |
161 | </td> | |
162 | <td> | |
163 | <p> | |
164 | Using the relation: p = 1 - exp(-x * λ) = -expm1(-x * λ) | |
165 | </p> | |
166 | </td> | |
167 | </tr> | |
168 | <tr> | |
169 | <td> | |
170 | <p> | |
171 | cdf complement | |
172 | </p> | |
173 | </td> | |
174 | <td> | |
175 | <p> | |
176 | Using the relation: q = exp(-x * λ) | |
177 | </p> | |
178 | </td> | |
179 | </tr> | |
180 | <tr> | |
181 | <td> | |
182 | <p> | |
183 | quantile | |
184 | </p> | |
185 | </td> | |
186 | <td> | |
187 | <p> | |
188 | Using the relation: x = -log(1-p) / λ = -log1p(-p) / λ | |
189 | </p> | |
190 | </td> | |
191 | </tr> | |
192 | <tr> | |
193 | <td> | |
194 | <p> | |
195 | quantile from the complement | |
196 | </p> | |
197 | </td> | |
198 | <td> | |
199 | <p> | |
200 | Using the relation: x = -log(q) / λ | |
201 | </p> | |
202 | </td> | |
203 | </tr> | |
204 | <tr> | |
205 | <td> | |
206 | <p> | |
207 | mean | |
208 | </p> | |
209 | </td> | |
210 | <td> | |
211 | <p> | |
212 | 1/λ | |
213 | </p> | |
214 | </td> | |
215 | </tr> | |
216 | <tr> | |
217 | <td> | |
218 | <p> | |
219 | standard deviation | |
220 | </p> | |
221 | </td> | |
222 | <td> | |
223 | <p> | |
224 | 1/λ | |
225 | </p> | |
226 | </td> | |
227 | </tr> | |
228 | <tr> | |
229 | <td> | |
230 | <p> | |
231 | mode | |
232 | </p> | |
233 | </td> | |
234 | <td> | |
235 | <p> | |
236 | 0 | |
237 | </p> | |
238 | </td> | |
239 | </tr> | |
240 | <tr> | |
241 | <td> | |
242 | <p> | |
243 | skewness | |
244 | </p> | |
245 | </td> | |
246 | <td> | |
247 | <p> | |
248 | 2 | |
249 | </p> | |
250 | </td> | |
251 | </tr> | |
252 | <tr> | |
253 | <td> | |
254 | <p> | |
255 | kurtosis | |
256 | </p> | |
257 | </td> | |
258 | <td> | |
259 | <p> | |
260 | 9 | |
261 | </p> | |
262 | </td> | |
263 | </tr> | |
264 | <tr> | |
265 | <td> | |
266 | <p> | |
267 | kurtosis excess | |
268 | </p> | |
269 | </td> | |
270 | <td> | |
271 | <p> | |
272 | 6 | |
273 | </p> | |
274 | </td> | |
275 | </tr> | |
276 | </tbody> | |
277 | </table></div> | |
278 | <h5> | |
279 | <a name="math_toolkit.dist_ref.dists.exp_dist.h4"></a> | |
280 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.exp_dist.references"></a></span><a class="link" href="exp_dist.html#math_toolkit.dist_ref.dists.exp_dist.references">references</a> | |
281 | </h5> | |
282 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
283 | <li class="listitem"> | |
284 | <a href="http://mathworld.wolfram.com/ExponentialDistribution.html" target="_top">Weisstein, | |
285 | Eric W. "Exponential Distribution." From MathWorld--A Wolfram | |
286 | Web Resource</a> | |
287 | </li> | |
288 | <li class="listitem"> | |
289 | <a href="http://documents.wolfram.com/calccenter/Functions/ListsMatrices/Statistics/ExponentialDistribution.html" target="_top">Wolfram | |
290 | Mathematica calculator</a> | |
291 | </li> | |
292 | <li class="listitem"> | |
293 | <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda3667.htm" target="_top">NIST | |
294 | Exploratory Data Analysis</a> | |
295 | </li> | |
296 | <li class="listitem"> | |
297 | <a href="http://en.wikipedia.org/wiki/Exponential_distribution" target="_top">Wikipedia | |
298 | Exponential distribution</a> | |
299 | </li> | |
300 | </ul></div> | |
301 | <p> | |
302 | (See also the reference documentation for the related <a class="link" href="extreme_dist.html" title="Extreme Value Distribution">Extreme | |
303 | Distributions</a>.) | |
304 | </p> | |
305 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> | |
306 | <a href="http://www.worldscibooks.com/mathematics/p191.html" target="_top">Extreme | |
307 | Value Distributions, Theory and Applications Samuel Kotz & Saralees | |
308 | Nadarajah</a> discuss the relationship of the types of extreme | |
309 | value distributions. | |
310 | </li></ul></div> | |
311 | </div> | |
312 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
313 | <td align="left"></td> | |
314 | <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, | |
315 | Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert | |
316 | Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, | |
317 | Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> | |
318 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
319 | 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>) | |
320 | </p> | |
321 | </div></td> | |
322 | </tr></table> | |
323 | <hr> | |
324 | <div class="spirit-nav"> | |
325 | <a accesskey="p" href="chi_squared_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="extreme_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> | |
326 | </div> | |
327 | </body> | |
328 | </html> |