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