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