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