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">
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="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>
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"><</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">></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">laplace_distribution</span><span class="special">;</span>
36 <span class="keyword">typedef</span> <span class="identifier">laplace_distribution</span><span class="special"><></span> <span class="identifier">laplace</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">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>
51 <span class="special">}}</span> <span class="comment">// namespaces</span>
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.
59 For location parameter <span class="emphasis"><em>μ</em></span> and scale parameter <span class="emphasis"><em>σ</em></span>,
60 it is defined by the probability density function:
62 <div class="blockquote"><blockquote class="blockquote"><p>
63 <span class="inlinemediaobject"><img src="../../../../equations/laplace_pdf.svg"></span>
65 </p></blockquote></div>
67 The location and scale parameters are equivalent to the mean and standard
68 deviation of the normal or Gaussian distribution.
71 The following graph illustrates the effect of the parameters μ and σ on the
72 PDF. Note that the domain of the random variable remains [-∞,+∞] irrespective
73 of the value of the location parameter:
75 <div class="blockquote"><blockquote class="blockquote"><p>
76 <span class="inlinemediaobject"><img src="../../../../graphs/laplace_pdf.svg" align="middle"></span>
78 </p></blockquote></div>
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
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>
87 Constructs a laplace distribution with location <span class="emphasis"><em>location</em></span>
88 and scale <span class="emphasis"><em>scale</em></span>.
91 The location parameter is the same as the mean of the random variate.
94 The scale parameter is proportional to the standard deviation of the random
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>.
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>
104 Returns the <span class="emphasis"><em>location</em></span> parameter of this distribution.
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>
109 Returns the <span class="emphasis"><em>scale</em></span> parameter of this distribution.
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
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>.
129 The domain of the random variable is [-∞,+∞].
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>
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.
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>
144 In the following table μ is the location parameter of the distribution, σ 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>.
148 <div class="informaltable"><table class="table">
174 Using the relation: pdf = e<sup>-abs(x-μ) / σ</sup> / (2 * σ)
189 x < μ : p = e<sup>(x-μ)/σ </sup> / σ
192 x >= μ : p = 1 - e<sup>(μ-x)/σ </sup> / σ
208 -x < μ : q = e<sup>(-x-μ)/σ </sup> / σ
211 -x >= μ : q = 1 - e<sup>(μ+x)/σ </sup> / σ
227 p < 0.5 : x = μ + σ * log(2*p)
230 p >= 0.5 : x = μ - σ * log(2-2*p)
237 quantile from the complement
245 q > 0.5: x = μ + σ*log(2-2*q)
248 q <=0.5: x = μ - σ*log( 2*q )
272 2 * σ<sup>2</sup>
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>
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.
336 <li class="listitem">
337 <a href="http://en.wikipedia.org/wiki/Laplace_distribution" target="_top">Laplace
340 <li class="listitem">
341 M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions,
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 © 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å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>)
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>