]>
Commit | Line | Data |
---|---|---|
1 | <html> | |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>Rayleigh 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="poisson_dist.html" title="Poisson Distribution"> | |
10 | <link rel="next" href="skew_normal_dist.html" title="Skew Normal 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="poisson_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="skew_normal_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.rayleigh"></a><a class="link" href="rayleigh.html" title="Rayleigh Distribution">Rayleigh 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">rayleigh</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> | |
31 | ||
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">rayleigh_distribution</span><span class="special">;</span> | |
35 | ||
36 | <span class="keyword">typedef</span> <span class="identifier">rayleigh_distribution</span><span class="special"><></span> <span class="identifier">rayleigh</span><span class="special">;</span> | |
37 | ||
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">rayleigh_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">rayleigh_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">sigma</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">sigma</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> | |
48 | <span class="special">};</span> | |
49 | ||
50 | <span class="special">}}</span> <span class="comment">// namespaces</span> | |
51 | </pre> | |
52 | <p> | |
53 | The <a href="http://en.wikipedia.org/wiki/Rayleigh_distribution" target="_top">Rayleigh | |
54 | distribution</a> is a continuous distribution with the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability | |
55 | density function</a>: | |
56 | </p> | |
57 | <p> | |
58 | f(x; sigma) = x * exp(-x<sup>2</sup>/2 σ<sup>2</sup>) / σ<sup>2</sup> | |
59 | </p> | |
60 | <p> | |
61 | For sigma parameter σ   > 0, and x > 0. | |
62 | </p> | |
63 | <p> | |
64 | The Rayleigh distribution is often used where two orthogonal components | |
65 | have an absolute value, for example, wind velocity and direction may be | |
66 | combined to yield a wind speed, or real and imaginary components may have | |
67 | absolute values that are Rayleigh distributed. | |
68 | </p> | |
69 | <p> | |
70 | The following graph illustrates how the Probability density Function(pdf) | |
71 | varies with the shape parameter σ: | |
72 | </p> | |
73 | <p> | |
74 | <span class="inlinemediaobject"><img src="../../../../graphs/rayleigh_pdf.svg" align="middle"></span> | |
75 | </p> | |
76 | <p> | |
77 | and the Cumulative Distribution Function (cdf) | |
78 | </p> | |
79 | <p> | |
80 | <span class="inlinemediaobject"><img src="../../../../graphs/rayleigh_cdf.svg" align="middle"></span> | |
81 | </p> | |
82 | <h5> | |
83 | <a name="math_toolkit.dist_ref.dists.rayleigh.h0"></a> | |
84 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.related_distributions"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.related_distributions">Related | |
85 | distributions</a> | |
86 | </h5> | |
87 | <p> | |
88 | The absolute value of two independent normal distributions X and Y, √ (X<sup>2</sup> + | |
89 | Y<sup>2</sup>) is a Rayleigh distribution. | |
90 | </p> | |
91 | <p> | |
92 | The <a href="http://en.wikipedia.org/wiki/Chi_distribution" target="_top">Chi</a>, | |
93 | <a href="http://en.wikipedia.org/wiki/Rice_distribution" target="_top">Rice</a> | |
94 | and <a href="http://en.wikipedia.org/wiki/Weibull_distribution" target="_top">Weibull</a> | |
95 | distributions are generalizations of the <a href="http://en.wikipedia.org/wiki/Rayleigh_distribution" target="_top">Rayleigh | |
96 | distribution</a>. | |
97 | </p> | |
98 | <h5> | |
99 | <a name="math_toolkit.dist_ref.dists.rayleigh.h1"></a> | |
100 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.member_functions"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.member_functions">Member | |
101 | Functions</a> | |
102 | </h5> | |
103 | <pre class="programlisting"><span class="identifier">rayleigh_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">sigma</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span> | |
104 | </pre> | |
105 | <p> | |
106 | Constructs a <a href="http://en.wikipedia.org/wiki/Rayleigh_distribution" target="_top">Rayleigh | |
107 | distribution</a> with σ <span class="emphasis"><em>sigma</em></span>. | |
108 | </p> | |
109 | <p> | |
110 | Requires that the σ parameter is greater than zero, otherwise calls <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>. | |
111 | </p> | |
112 | <pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">sigma</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> | |
113 | </pre> | |
114 | <p> | |
115 | Returns the <span class="emphasis"><em>sigma</em></span> parameter of this distribution. | |
116 | </p> | |
117 | <h5> | |
118 | <a name="math_toolkit.dist_ref.dists.rayleigh.h2"></a> | |
119 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.non_member_accessors"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.non_member_accessors">Non-member | |
120 | Accessors</a> | |
121 | </h5> | |
122 | <p> | |
123 | All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor | |
124 | functions</a> that are generic to all distributions are supported: | |
125 | <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>, | |
126 | <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>, | |
127 | <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>, | |
128 | <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>, | |
129 | <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>, | |
130 | <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>, | |
131 | <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>, | |
132 | <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>. | |
133 | </p> | |
134 | <p> | |
135 | The domain of the random variable is [0, max_value]. | |
136 | </p> | |
137 | <h5> | |
138 | <a name="math_toolkit.dist_ref.dists.rayleigh.h3"></a> | |
139 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.accuracy"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.accuracy">Accuracy</a> | |
140 | </h5> | |
141 | <p> | |
142 | The Rayleigh distribution is implemented in terms of the standard library | |
143 | <code class="computeroutput"><span class="identifier">sqrt</span></code> and <code class="computeroutput"><span class="identifier">exp</span></code> and as such should have very low | |
144 | error rates. Some constants such as skewness and kurtosis were calculated | |
145 | using NTL RR type with 150-bit accuracy, about 50 decimal digits. | |
146 | </p> | |
147 | <h5> | |
148 | <a name="math_toolkit.dist_ref.dists.rayleigh.h4"></a> | |
149 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.implementation"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.implementation">Implementation</a> | |
150 | </h5> | |
151 | <p> | |
152 | In the following table σ   is the sigma parameter of the distribution, <span class="emphasis"><em>x</em></span> | |
153 | is the random variate, <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q | |
154 | = 1-p</em></span>. | |
155 | </p> | |
156 | <div class="informaltable"><table class="table"> | |
157 | <colgroup> | |
158 | <col> | |
159 | <col> | |
160 | </colgroup> | |
161 | <thead><tr> | |
162 | <th> | |
163 | <p> | |
164 | Function | |
165 | </p> | |
166 | </th> | |
167 | <th> | |
168 | <p> | |
169 | Implementation Notes | |
170 | </p> | |
171 | </th> | |
172 | </tr></thead> | |
173 | <tbody> | |
174 | <tr> | |
175 | <td> | |
176 | <p> | |
177 | ||
178 | </p> | |
179 | </td> | |
180 | <td> | |
181 | <p> | |
182 | Using the relation: pdf = x * exp(-x<sup>2</sup>)/2 σ<sup>2</sup> | |
183 | </p> | |
184 | </td> | |
185 | </tr> | |
186 | <tr> | |
187 | <td> | |
188 | <p> | |
189 | cdf | |
190 | </p> | |
191 | </td> | |
192 | <td> | |
193 | <p> | |
194 | Using the relation: p = 1 - exp(-x<sup>2</sup>/2) σ<sup>2</sup>   = -<a class="link" href="../../powers/expm1.html" title="expm1">expm1</a>(-x<sup>2</sup>/2) | |
195 | σ<sup>2</sup> | |
196 | </p> | |
197 | </td> | |
198 | </tr> | |
199 | <tr> | |
200 | <td> | |
201 | <p> | |
202 | cdf complement | |
203 | </p> | |
204 | </td> | |
205 | <td> | |
206 | <p> | |
207 | Using the relation: q = exp(-x<sup>2</sup>/ 2) * σ<sup>2</sup> | |
208 | </p> | |
209 | </td> | |
210 | </tr> | |
211 | <tr> | |
212 | <td> | |
213 | <p> | |
214 | quantile | |
215 | </p> | |
216 | </td> | |
217 | <td> | |
218 | <p> | |
219 | Using the relation: x = sqrt(-2 * σ <sup>2</sup>) * log(1 - p)) = sqrt(-2 | |
220 | * σ <sup>2</sup>) * <a class="link" href="../../powers/log1p.html" title="log1p">log1p</a>(-p)) | |
221 | </p> | |
222 | </td> | |
223 | </tr> | |
224 | <tr> | |
225 | <td> | |
226 | <p> | |
227 | quantile from the complement | |
228 | </p> | |
229 | </td> | |
230 | <td> | |
231 | <p> | |
232 | Using the relation: x = sqrt(-2 * σ <sup>2</sup>) * log(q)) | |
233 | </p> | |
234 | </td> | |
235 | </tr> | |
236 | <tr> | |
237 | <td> | |
238 | <p> | |
239 | mean | |
240 | </p> | |
241 | </td> | |
242 | <td> | |
243 | <p> | |
244 | σ * sqrt(π/2) | |
245 | </p> | |
246 | </td> | |
247 | </tr> | |
248 | <tr> | |
249 | <td> | |
250 | <p> | |
251 | variance | |
252 | </p> | |
253 | </td> | |
254 | <td> | |
255 | <p> | |
256 | σ<sup>2</sup> * (4 - π/2) | |
257 | </p> | |
258 | </td> | |
259 | </tr> | |
260 | <tr> | |
261 | <td> | |
262 | <p> | |
263 | mode | |
264 | </p> | |
265 | </td> | |
266 | <td> | |
267 | <p> | |
268 | σ | |
269 | </p> | |
270 | </td> | |
271 | </tr> | |
272 | <tr> | |
273 | <td> | |
274 | <p> | |
275 | skewness | |
276 | </p> | |
277 | </td> | |
278 | <td> | |
279 | <p> | |
280 | Constant from <a href="http://mathworld.wolfram.com/RayleighDistribution.html" target="_top">Weisstein, | |
281 | Eric W. "Weibull Distribution." From MathWorld--A Wolfram | |
282 | Web Resource.</a> | |
283 | </p> | |
284 | </td> | |
285 | </tr> | |
286 | <tr> | |
287 | <td> | |
288 | <p> | |
289 | kurtosis | |
290 | </p> | |
291 | </td> | |
292 | <td> | |
293 | <p> | |
294 | Constant from <a href="http://mathworld.wolfram.com/RayleighDistribution.html" target="_top">Weisstein, | |
295 | Eric W. "Weibull Distribution." From MathWorld--A Wolfram | |
296 | Web Resource.</a> | |
297 | </p> | |
298 | </td> | |
299 | </tr> | |
300 | <tr> | |
301 | <td> | |
302 | <p> | |
303 | kurtosis excess | |
304 | </p> | |
305 | </td> | |
306 | <td> | |
307 | <p> | |
308 | Constant from <a href="http://mathworld.wolfram.com/RayleighDistribution.html" target="_top">Weisstein, | |
309 | Eric W. "Weibull Distribution." From MathWorld--A Wolfram | |
310 | Web Resource.</a> | |
311 | </p> | |
312 | </td> | |
313 | </tr> | |
314 | </tbody> | |
315 | </table></div> | |
316 | <h5> | |
317 | <a name="math_toolkit.dist_ref.dists.rayleigh.h5"></a> | |
318 | <span class="phrase"><a name="math_toolkit.dist_ref.dists.rayleigh.references"></a></span><a class="link" href="rayleigh.html#math_toolkit.dist_ref.dists.rayleigh.references">References</a> | |
319 | </h5> | |
320 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
321 | <li class="listitem"> | |
322 | <a href="http://en.wikipedia.org/wiki/Rayleigh_distribution" target="_top">http://en.wikipedia.org/wiki/Rayleigh_distribution</a> | |
323 | </li> | |
324 | <li class="listitem"> | |
325 | <a href="http://mathworld.wolfram.com/RayleighDistribution.html" target="_top">Weisstein, | |
326 | Eric W. "Rayleigh Distribution." From MathWorld--A Wolfram | |
327 | Web Resource.</a> | |
328 | </li> | |
329 | </ul></div> | |
330 | </div> | |
331 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
332 | <td align="left"></td> | |
333 | <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, | |
334 | Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert | |
335 | Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, | |
336 | Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> | |
337 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
338 | 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>) | |
339 | </p> | |
340 | </div></td> | |
341 | </tr></table> | |
342 | <hr> | |
343 | <div class="spirit-nav"> | |
344 | <a accesskey="p" href="poisson_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="skew_normal_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> | |
345 | </div> | |
346 | </body> | |
347 | </html> |