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">
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 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>
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 15. 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
μ   and scale parameter
σ  , it is defined by the probability
63 <span class=
"inlinemediaobject"><img src=
"../../../../equations/laplace_pdf.svg"></span>
66 The location and scale parameters are equivalent to the mean and standard
67 deviation of the normal or Gaussian distribution.
70 The following graph illustrates the effect of the parameters
μ   and
σ   on the
71 PDF. Note that the domain of the random variable remains [-
∞,+
∞] irrespective
72 of the value of the location parameter:
75 <span class=
"inlinemediaobject"><img src=
"../../../../graphs/laplace_pdf.svg" align=
"middle"></span>
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
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>
85 Constructs a laplace distribution with location
<span class=
"emphasis"><em>location
</em></span>
86 and scale
<span class=
"emphasis"><em>scale
</em></span>.
89 The location parameter is the same as the mean of the random variate.
92 The scale parameter is proportional to the standard deviation of the random
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>.
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>
102 Returns the
<span class=
"emphasis"><em>location
</em></span> parameter of this distribution.
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>
107 Returns the
<span class=
"emphasis"><em>scale
</em></span> parameter of this distribution.
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
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>.
127 The domain of the random variable is [-
∞,+
∞].
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>
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.
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>
142 In the following table
μ is the location parameter of the distribution,
σ 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>.
146 <div class=
"informaltable"><table class=
"table">
172 Using the relation: pdf = e
<sup>-abs(x-
μ) /
σ</sup> / (
2 *
σ)
187 x
< μ : p = e
<sup>(x-
μ)/
σ </sup> /
σ
190 x
>=
μ : p =
1 - e
<sup>(
μ-x)/
σ </sup> /
σ
206 -x
< μ : q = e
<sup>(-x-
μ)/
σ </sup> /
σ
209 -x
>=
μ : q =
1 - e
<sup>(
μ+x)/
σ </sup> /
σ
225 p
< 0.5 : x =
μ +
σ * log(
2*p)
228 p
>=
0.5 : x =
μ -
σ * log(
2-
2*p)
235 quantile from the complement
243 q
> 0.5: x =
μ +
σ*log(
2-
2*q)
246 q
<=
0.5: x =
μ -
σ*log(
2*q )
270 2 *
σ<sup>2</sup>
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>
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.
334 <li class=
"listitem">
335 <a href=
"http://en.wikipedia.org/wiki/Laplace_distribution" target=
"_top">Laplace
338 <li class=
"listitem">
339 M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions,
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
© 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
å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>)
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>