]>
Commit | Line | Data |
---|---|---|
1 | [section:laplace_dist Laplace Distribution] | |
2 | ||
3 | ``#include <boost/math/distributions/laplace.hpp>`` | |
4 | ||
5 | namespace boost{ namespace math{ | |
6 | ||
7 | template <class RealType = double, | |
8 | class ``__Policy`` = ``__policy_class`` > | |
9 | class laplace_distribution; | |
10 | ||
11 | typedef laplace_distribution<> laplace; | |
12 | ||
13 | template <class RealType, class ``__Policy``> | |
14 | class laplace_distribution | |
15 | { | |
16 | public: | |
17 | typedef RealType value_type; | |
18 | typedef Policy policy_type; | |
19 | // Construct: | |
20 | laplace_distribution(RealType location = 0, RealType scale = 1); | |
21 | // Accessors: | |
22 | RealType location()const; | |
23 | RealType scale()const; | |
24 | }; | |
25 | ||
26 | }} // namespaces | |
27 | ||
28 | Laplace distribution is the distribution of differences between two independent variates | |
29 | with identical exponential distributions (Abramowitz and Stegun 1972, p. 930). | |
30 | It is also called the double exponential distribution. | |
31 | ||
32 | [/ Wikipedia definition is The difference between two independent identically distributed | |
33 | exponential random variables is governed by a Laplace distribution.] | |
34 | ||
35 | For location parameter [mu][space] and scale parameter [sigma][space], it is defined by the | |
36 | probability density function: | |
37 | ||
38 | [equation laplace_pdf] | |
39 | ||
40 | The location and scale parameters are equivalent to the mean and | |
41 | standard deviation of the normal or Gaussian distribution. | |
42 | ||
43 | The following graph illustrates the effect of the | |
44 | parameters [mu][space] and [sigma][space] on the PDF. | |
45 | Note that the domain of the random variable remains | |
46 | \[-[infin],+[infin]\] irrespective of the value of the location parameter: | |
47 | ||
48 | [graph laplace_pdf] | |
49 | ||
50 | [h4 Member Functions] | |
51 | ||
52 | laplace_distribution(RealType location = 0, RealType scale = 1); | |
53 | ||
54 | Constructs a laplace distribution with location /location/ and | |
55 | scale /scale/. | |
56 | ||
57 | The location parameter is the same as the mean of the random variate. | |
58 | ||
59 | The scale parameter is proportional to the standard deviation of the random variate. | |
60 | ||
61 | Requires that the scale parameter is greater than zero, otherwise calls | |
62 | __domain_error. | |
63 | ||
64 | RealType location()const; | |
65 | ||
66 | Returns the /location/ parameter of this distribution. | |
67 | ||
68 | RealType scale()const; | |
69 | ||
70 | Returns the /scale/ parameter of this distribution. | |
71 | ||
72 | [h4 Non-member Accessors] | |
73 | ||
74 | All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions] that are generic to all | |
75 | distributions are supported: __usual_accessors. | |
76 | ||
77 | The domain of the random variable is \[-[infin],+[infin]\]. | |
78 | ||
79 | [h4 Accuracy] | |
80 | ||
81 | The laplace distribution is implemented in terms of the | |
82 | standard library log and exp functions and as such should have very small errors. | |
83 | ||
84 | [h4 Implementation] | |
85 | ||
86 | In the following table [mu] is the location parameter of the distribution, | |
87 | [sigma] is its scale parameter, /x/ is the random variate, /p/ is the probability | |
88 | and its complement /q = 1-p/. | |
89 | ||
90 | [table | |
91 | [[Function][Implementation Notes]] | |
92 | [[pdf][Using the relation: pdf = e[super -abs(x-[mu]) \/ [sigma]] \/ (2 * [sigma]) ]] | |
93 | [[cdf][Using the relations: | |
94 | ||
95 | x < [mu] : p = e[super (x-[mu])/[sigma] ] \/ [sigma] | |
96 | ||
97 | x >= [mu] : p = 1 - e[super ([mu]-x)/[sigma] ] \/ [sigma] | |
98 | ]] | |
99 | [[cdf complement][Using the relation: | |
100 | ||
101 | -x < [mu] : q = e[super (-x-[mu])/[sigma] ] \/ [sigma] | |
102 | ||
103 | -x >= [mu] : q = 1 - e[super ([mu]+x)/[sigma] ] \/ [sigma] | |
104 | ]] | |
105 | [[quantile][Using the relations: | |
106 | ||
107 | p < 0.5 : x = [mu] + [sigma] * log(2*p) | |
108 | ||
109 | p >= 0.5 : x = [mu] - [sigma] * log(2-2*p) | |
110 | ]] | |
111 | [[quantile from the complement][Using the relation: | |
112 | ||
113 | q > 0.5: x = [mu] + [sigma]*log(2-2*q) | |
114 | ||
115 | q <=0.5: x = [mu] - [sigma]*log( 2*q ) | |
116 | ]] | |
117 | [[mean][[mu]]] | |
118 | [[variance][2 * [sigma][super 2] ]] | |
119 | [[mode][[mu]]] | |
120 | [[skewness][0]] | |
121 | [[kurtosis][6]] | |
122 | [[kurtosis excess][3]] | |
123 | ] | |
124 | ||
125 | [h4 References] | |
126 | ||
127 | * [@http://mathworld.wolfram.com/LaplaceDistribution.html Weisstein, Eric W. "Laplace Distribution."] From MathWorld--A Wolfram Web Resource. | |
128 | ||
129 | * [@http://en.wikipedia.org/wiki/Laplace_distribution Laplace Distribution] | |
130 | ||
131 | * M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions, 1972, p. 930. | |
132 | ||
133 | [endsect][/section:laplace_dist laplace] | |
134 | ||
135 | [/ | |
136 | Copyright 2008, 2009 John Maddock, Paul A. Bristow and M.A. (Thijs) van den Berg. | |
137 | Distributed under the Boost Software License, Version 1.0. | |
138 | (See accompanying file LICENSE_1_0.txt or copy at | |
139 | http://www.boost.org/LICENSE_1_0.txt). | |
140 | ] | |
141 |