Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / math / doc / html / math_toolkit / dist_ref / dists / laplace_dist.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Laplace 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="inverse_gaussian_dist.html" title="Inverse Gaussian (or Inverse Normal) Distribution">
10 <link rel="next" href="logistic_dist.html" title="Logistic 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="inverse_gaussian_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="logistic_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.laplace_dist"></a><a class="link" href="laplace_dist.html" title="Laplace Distribution">Laplace Distribution</a>
28 </h4></div></div></div>
29 <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">laplace</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</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>
31
32 <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>
33           <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter&#160;20.&#160;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&lt;&gt;</a> <span class="special">&gt;</span>
34 <span class="keyword">class</span> <span class="identifier">laplace_distribution</span><span class="special">;</span>
35
36 <span class="keyword">typedef</span> <span class="identifier">laplace_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">laplace</span><span class="special">;</span>
37
38 <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="Chapter&#160;20.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
39 <span class="keyword">class</span> <span class="identifier">laplace_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>
44    <span class="comment">// Construct:</span>
45    <span class="identifier">laplace_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">scale</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
46    <span class="comment">// Accessors:</span>
47    <span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
48    <span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
49 <span class="special">};</span>
50
51 <span class="special">}}</span> <span class="comment">// namespaces</span>
52 </pre>
53 <p>
54           Laplace distribution is the distribution of differences between two independent
55           variates with identical exponential distributions (Abramowitz and Stegun
56           1972, p. 930). It is also called the double exponential distribution.
57         </p>
58 <p>
59           For location parameter <span class="emphasis"><em>&#956;</em></span> and scale parameter <span class="emphasis"><em>&#963;</em></span>,
60           it is defined by the probability density function:
61         </p>
62 <div class="blockquote"><blockquote class="blockquote"><p>
63             <span class="inlinemediaobject"><img src="../../../../equations/laplace_pdf.svg"></span>
64
65           </p></blockquote></div>
66 <p>
67           The location and scale parameters are equivalent to the mean and standard
68           deviation of the normal or Gaussian distribution.
69         </p>
70 <p>
71           The following graph illustrates the effect of the parameters &#956; and &#963; on the
72           PDF. Note that the domain of the random variable remains [-&#8734;,+&#8734;] irrespective
73           of the value of the location parameter:
74         </p>
75 <div class="blockquote"><blockquote class="blockquote"><p>
76             <span class="inlinemediaobject"><img src="../../../../graphs/laplace_pdf.svg" align="middle"></span>
77
78           </p></blockquote></div>
79 <h5>
80 <a name="math_toolkit.dist_ref.dists.laplace_dist.h0"></a>
81           <span class="phrase"><a name="math_toolkit.dist_ref.dists.laplace_dist.member_functions"></a></span><a class="link" href="laplace_dist.html#math_toolkit.dist_ref.dists.laplace_dist.member_functions">Member
82           Functions</a>
83         </h5>
84 <pre class="programlisting"><span class="identifier">laplace_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">scale</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
85 </pre>
86 <p>
87           Constructs a laplace distribution with location <span class="emphasis"><em>location</em></span>
88           and scale <span class="emphasis"><em>scale</em></span>.
89         </p>
90 <p>
91           The location parameter is the same as the mean of the random variate.
92         </p>
93 <p>
94           The scale parameter is proportional to the standard deviation of the random
95           variate.
96         </p>
97 <p>
98           Requires that the scale parameter is greater than zero, otherwise calls
99           <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
100         </p>
101 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
102 </pre>
103 <p>
104           Returns the <span class="emphasis"><em>location</em></span> parameter of this distribution.
105         </p>
106 <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
107 </pre>
108 <p>
109           Returns the <span class="emphasis"><em>scale</em></span> parameter of this distribution.
110         </p>
111 <h5>
112 <a name="math_toolkit.dist_ref.dists.laplace_dist.h1"></a>
113           <span class="phrase"><a name="math_toolkit.dist_ref.dists.laplace_dist.non_member_accessors"></a></span><a class="link" href="laplace_dist.html#math_toolkit.dist_ref.dists.laplace_dist.non_member_accessors">Non-member
114           Accessors</a>
115         </h5>
116 <p>
117           All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
118           functions</a> that are generic to all distributions are supported:
119           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
120           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
121           <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>,
122           <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>,
123           <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>,
124           <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
125           <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>,
126           <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>.
127         </p>
128 <p>
129           The domain of the random variable is [-&#8734;,+&#8734;].
130         </p>
131 <h5>
132 <a name="math_toolkit.dist_ref.dists.laplace_dist.h2"></a>
133           <span class="phrase"><a name="math_toolkit.dist_ref.dists.laplace_dist.accuracy"></a></span><a class="link" href="laplace_dist.html#math_toolkit.dist_ref.dists.laplace_dist.accuracy">Accuracy</a>
134         </h5>
135 <p>
136           The laplace distribution is implemented in terms of the standard library
137           log and exp functions and as such should have very small errors.
138         </p>
139 <h5>
140 <a name="math_toolkit.dist_ref.dists.laplace_dist.h3"></a>
141           <span class="phrase"><a name="math_toolkit.dist_ref.dists.laplace_dist.implementation"></a></span><a class="link" href="laplace_dist.html#math_toolkit.dist_ref.dists.laplace_dist.implementation">Implementation</a>
142         </h5>
143 <p>
144           In the following table &#956; is the location parameter of the distribution, &#963; is
145           its scale parameter, <span class="emphasis"><em>x</em></span> is the random variate, <span class="emphasis"><em>p</em></span>
146           is the probability and its complement <span class="emphasis"><em>q = 1-p</em></span>.
147         </p>
148 <div class="informaltable"><table class="table">
149 <colgroup>
150 <col>
151 <col>
152 </colgroup>
153 <thead><tr>
154 <th>
155                   <p>
156                     Function
157                   </p>
158                 </th>
159 <th>
160                   <p>
161                     Implementation Notes
162                   </p>
163                 </th>
164 </tr></thead>
165 <tbody>
166 <tr>
167 <td>
168                   <p>
169                     pdf
170                   </p>
171                 </td>
172 <td>
173                   <p>
174                     Using the relation: pdf = e<sup>-abs(x-&#956;) / &#963;</sup> / (2 * &#963;)
175                   </p>
176                 </td>
177 </tr>
178 <tr>
179 <td>
180                   <p>
181                     cdf
182                   </p>
183                 </td>
184 <td>
185                   <p>
186                     Using the relations:
187                   </p>
188                   <p>
189                     x &lt; &#956; : p = e<sup>(x-&#956;)/&#963; </sup> / &#963;
190                   </p>
191                   <p>
192                     x &gt;= &#956; : p = 1 - e<sup>(&#956;-x)/&#963; </sup> / &#963;
193
194                   </p>
195                 </td>
196 </tr>
197 <tr>
198 <td>
199                   <p>
200                     cdf complement
201                   </p>
202                 </td>
203 <td>
204                   <p>
205                     Using the relation:
206                   </p>
207                   <p>
208                     -x &lt; &#956; : q = e<sup>(-x-&#956;)/&#963; </sup> / &#963;
209                   </p>
210                   <p>
211                     -x &gt;= &#956; : q = 1 - e<sup>(&#956;+x)/&#963; </sup> / &#963;
212
213                   </p>
214                 </td>
215 </tr>
216 <tr>
217 <td>
218                   <p>
219                     quantile
220                   </p>
221                 </td>
222 <td>
223                   <p>
224                     Using the relations:
225                   </p>
226                   <p>
227                     p &lt; 0.5 : x = &#956; + &#963; * log(2*p)
228                   </p>
229                   <p>
230                     p &gt;= 0.5 : x = &#956; - &#963; * log(2-2*p)
231                   </p>
232                 </td>
233 </tr>
234 <tr>
235 <td>
236                   <p>
237                     quantile from the complement
238                   </p>
239                 </td>
240 <td>
241                   <p>
242                     Using the relation:
243                   </p>
244                   <p>
245                     q &gt; 0.5: x = &#956; + &#963;*log(2-2*q)
246                   </p>
247                   <p>
248                     q &lt;=0.5: x = &#956; - &#963;*log( 2*q )
249                   </p>
250                 </td>
251 </tr>
252 <tr>
253 <td>
254                   <p>
255                     mean
256                   </p>
257                 </td>
258 <td>
259                   <p>
260                     &#956;
261                   </p>
262                 </td>
263 </tr>
264 <tr>
265 <td>
266                   <p>
267                     variance
268                   </p>
269                 </td>
270 <td>
271                   <p>
272                     2 * &#963;<sup>2</sup>
273                   </p>
274                 </td>
275 </tr>
276 <tr>
277 <td>
278                   <p>
279                     mode
280                   </p>
281                 </td>
282 <td>
283                   <p>
284                     &#956;
285                   </p>
286                 </td>
287 </tr>
288 <tr>
289 <td>
290                   <p>
291                     skewness
292                   </p>
293                 </td>
294 <td>
295                   <p>
296                     0
297                   </p>
298                 </td>
299 </tr>
300 <tr>
301 <td>
302                   <p>
303                     kurtosis
304                   </p>
305                 </td>
306 <td>
307                   <p>
308                     6
309                   </p>
310                 </td>
311 </tr>
312 <tr>
313 <td>
314                   <p>
315                     kurtosis excess
316                   </p>
317                 </td>
318 <td>
319                   <p>
320                     3
321                   </p>
322                 </td>
323 </tr>
324 </tbody>
325 </table></div>
326 <h5>
327 <a name="math_toolkit.dist_ref.dists.laplace_dist.h4"></a>
328           <span class="phrase"><a name="math_toolkit.dist_ref.dists.laplace_dist.references"></a></span><a class="link" href="laplace_dist.html#math_toolkit.dist_ref.dists.laplace_dist.references">References</a>
329         </h5>
330 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
331 <li class="listitem">
332               <a href="http://mathworld.wolfram.com/LaplaceDistribution.html" target="_top">Weisstein,
333               Eric W. "Laplace Distribution."</a> From MathWorld--A
334               Wolfram Web Resource.
335             </li>
336 <li class="listitem">
337               <a href="http://en.wikipedia.org/wiki/Laplace_distribution" target="_top">Laplace
338               Distribution</a>
339             </li>
340 <li class="listitem">
341               M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions,
342               1972, p. 930.
343             </li>
344 </ul></div>
345 </div>
346 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
347 <td align="left"></td>
348 <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
349       Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
350       Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
351       R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
352       Daryle Walker and Xiaogang Zhang<p>
353         Distributed under the Boost Software License, Version 1.0. (See accompanying
354         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>)
355       </p>
356 </div></td>
357 </tr></table>
358 <hr>
359 <div class="spirit-nav">
360 <a accesskey="p" href="inverse_gaussian_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="logistic_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
361 </div>
362 </body>
363 </html>