{"id":2523,"date":"2026-02-02T09:53:10","date_gmt":"2026-02-02T09:53:10","guid":{"rendered":"https:\/\/demo.materiamedica.net\/demo6\/?p=2523"},"modified":"2026-02-02T09:53:10","modified_gmt":"2026-02-02T09:53:10","slug":"chapter-13-rayleigh-distribution","status":"publish","type":"post","link":"https:\/\/demo.materiamedica.net\/demo6\/chapter-13-rayleigh-distribution\/","title":{"rendered":"Chapter 13: Rayleigh Distribution"},"content":{"rendered":"<h3 dir=\"auto\">1. What is the Rayleigh distribution really?<\/h3>\n<p dir=\"auto\">The <strong>Rayleigh distribution<\/strong> describes the <strong>magnitude<\/strong> (absolute value \/ length) of a <strong>two-dimensional random vector<\/strong> whose components are <strong>independent normal random variables with zero mean and equal variance<\/strong>.<\/p>\n<p dir=\"auto\">In simpler words:<\/p>\n<blockquote dir=\"auto\">\n<p dir=\"auto\">If you have two independent normal random variables X ~ N(0, \u03c3\u00b2) and Y ~ N(0, \u03c3\u00b2), then the distance from the origin R = \u221a(X\u00b2 + Y\u00b2) follows a <strong>Rayleigh distribution<\/strong> with scale parameter \u03c3.<\/p>\n<\/blockquote>\n<p dir=\"auto\"><strong>Key intuition<\/strong> (say this sentence out loud):<\/p>\n<blockquote dir=\"auto\">\n<p dir=\"auto\">Rayleigh distribution = distribution of the <strong>distance from origin<\/strong> in 2D when you add two independent Gaussian noises with same variance.<\/p>\n<\/blockquote>\n<p dir=\"auto\">This situation appears <strong>very frequently<\/strong> when you measure <strong>amplitude<\/strong> or <strong>envelope<\/strong> of a signal that consists of many small random reflections \/ contributions.<\/p>\n<h3 dir=\"auto\">2. The most important properties (write these down)<\/h3>\n<div>\n<div dir=\"auto\">\n<table dir=\"auto\">\n<thead>\n<tr>\n<th data-col-size=\"lg\">Parameter<\/th>\n<th data-col-size=\"xl\">Symbol<\/th>\n<th data-col-size=\"xs\">Meaning \/ Formula<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td data-col-size=\"lg\">Scale parameter<\/td>\n<td data-col-size=\"xl\">\u03c3<\/td>\n<td data-col-size=\"xs\">Controls spread (\u03c3 &gt; 0)<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"lg\">Support<\/td>\n<td data-col-size=\"xl\">x \u2265 0<\/td>\n<td data-col-size=\"xs\"><\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"lg\">Probability density<\/td>\n<td data-col-size=\"xl\">f(x) = (x \/ \u03c3\u00b2) \u00d7 exp(\u2212x\u00b2 \/ (2\u03c3\u00b2)) for x \u2265 0<\/td>\n<td data-col-size=\"xs\"><\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"lg\">Cumulative (CDF)<\/td>\n<td data-col-size=\"xl\">F(x) = 1 \u2212 exp(\u2212x\u00b2 \/ (2\u03c3\u00b2))<\/td>\n<td data-col-size=\"xs\"><\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"lg\">Mean<\/td>\n<td data-col-size=\"xl\">E[R] = \u03c3 \u00d7 \u221a(\u03c0\/2) \u2248 1.2533 \u03c3<\/td>\n<td data-col-size=\"xs\"><\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"lg\">Variance<\/td>\n<td data-col-size=\"xl\">Var(R) = (4\u2212\u03c0)\/2 \u00d7 \u03c3\u00b2 \u2248 0.4292 \u03c3\u00b2<\/td>\n<td data-col-size=\"xs\"><\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"lg\">Mode<\/td>\n<td data-col-size=\"xl\">\u03c3 (the peak is exactly at \u03c3)<\/td>\n<td data-col-size=\"xs\"><\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"lg\">Median<\/td>\n<td data-col-size=\"xl\">\u03c3 \u00d7 \u221a(ln 2) \u2248 1.177 \u03c3<\/td>\n<td data-col-size=\"xs\"><\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"lg\">Most probable value<\/td>\n<td data-col-size=\"xl\">\u03c3<\/td>\n<td data-col-size=\"xs\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div><\/div>\n<\/div>\n<\/div>\n<p dir=\"auto\"><strong>Very useful rule of thumb<\/strong>:<\/p>\n<ul dir=\"auto\">\n<li>About <strong>63%<\/strong> of values are <strong>below \u03c3 \u00d7 \u221a(ln 4) \u2248 1.177\u03c3<\/strong> (median)<\/li>\n<li>The mean is roughly <strong>1.25\u03c3<\/strong><\/li>\n<li>Standard deviation is roughly <strong>0.655\u03c3<\/strong><\/li>\n<\/ul>\n<h3 dir=\"auto\">3. Generating Rayleigh random numbers in NumPy \/ SciPy<\/h3>\n<div dir=\"auto\">\n<div data-testid=\"code-block\">\n<div>\n<div>Python<\/div>\n<div>\n<pre tabindex=\"0\"><code># Rayleigh with scale \u03c3 = 2 (most common way)\r\nrayleigh_data = stats.rayleigh.rvs(scale=2, size=80000)\r\n\r\nprint(\"First 10 values:\", rayleigh_data[:10].round(3))\r\nprint(\"Sample mean:\", rayleigh_data.mean().round(3))\r\nprint(\"Theoretical mean:\", 2 * np.sqrt(np.pi\/2).round(3))  # \u2248 2.5066\r\nprint(\"Sample std :\", rayleigh_data.std().round(3))\r\nprint(\"Theoretical std:\", 2 * np.sqrt((4-np.pi)\/2).round(3))  # \u2248 1.047<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p dir=\"auto\">Alternative way using NumPy (very educational):<\/p>\n<div dir=\"auto\">\n<div data-testid=\"code-block\">\n<div>\n<div>Python<\/div>\n<div>\n<pre tabindex=\"0\"><code>sigma = 2.0\r\nX = np.random.normal(0, sigma, 100000)\r\nY = np.random.normal(0, sigma, 100000)\r\nrayleigh_manual = np.sqrt(X**2 + Y**2)\r\n\r\n# Should be almost identical to stats.rayleigh.rvs(scale=sigma)<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3 dir=\"auto\">4. Visualizing Rayleigh distribution (very important)<\/h3>\n<div dir=\"auto\">\n<div data-testid=\"code-block\">\n<div>\n<div>Python<\/div>\n<div>\n<pre tabindex=\"0\"><code>fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 5.5))\r\n\r\nscales = [1.0, 2.0, 4.0, 8.0]\r\n\r\nx = np.linspace(0, 30, 1000)\r\n\r\nfor s in scales:\r\n    y = stats.rayleigh.pdf(x, scale=s)\r\n    ax1.plot(x, y, lw=2.3, label=f\"\u03c3 = {s}\", alpha=0.9)\r\n\r\nax1.set_title(\"Rayleigh PDF \u2013 different scale parameters\", fontsize=13)\r\nax1.set_xlabel(\"Value (r)\", fontsize=11)\r\nax1.set_ylabel(\"Density\", fontsize=11)\r\nax1.set_xlim(0, 30)\r\nax1.legend(title=\"Scale parameter \u03c3\", fontsize=11)\r\n\r\n# Cumulative distribution function (CDF)\r\nfor s in scales:\r\n    ax2.plot(x, stats.rayleigh.cdf(x, scale=s), lw=2.3, label=f\"\u03c3 = {s}\")\r\n\r\nax2.set_title(\"Rayleigh CDF\", fontsize=13)\r\nax2.set_xlabel(\"Value (r)\", fontsize=11)\r\nax2.set_ylabel(\"Cumulative probability\", fontsize=11)\r\nax2.legend(title=\"Scale parameter \u03c3\")\r\n\r\nplt.tight_layout()\r\nplt.show()<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p dir=\"auto\"><strong>What you should always notice<\/strong>:<\/p>\n<ul dir=\"auto\">\n<li>Always starts at 0 when x=0<\/li>\n<li>Has a <strong>peak<\/strong> (mode) exactly at <strong>\u03c3<\/strong><\/li>\n<li>Never negative values<\/li>\n<li>Right-skewed, but less skewed than exponential<\/li>\n<li>Larger \u03c3 \u2192 distribution stretches to the right<\/li>\n<li>CDF always starts at 0 and approaches 1 smoothly<\/li>\n<\/ul>\n<h3 dir=\"auto\">5. Real-world situations where Rayleigh appears naturally<\/h3>\n<div>\n<div dir=\"auto\">\n<table dir=\"auto\">\n<thead>\n<tr>\n<th data-col-size=\"md\">Domain<\/th>\n<th data-col-size=\"lg\">Typical use of Rayleigh distribution<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td data-col-size=\"md\">Wireless communications (fading)<\/td>\n<td data-col-size=\"lg\">Magnitude of complex Gaussian fading channel (Rayleigh fading)<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Radar \/ sonar<\/td>\n<td data-col-size=\"lg\">Amplitude of noise \/ target echo in non-coherent detection<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Acoustics \/ audio processing<\/td>\n<td data-col-size=\"lg\">Envelope of narrowband Gaussian noise<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">MRI \/ medical imaging<\/td>\n<td data-col-size=\"lg\">Noise magnitude in magnitude images<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Wind speed modeling<\/td>\n<td data-col-size=\"lg\">Speed of wind (often Rayleigh or Weibull)<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Line-of-sight + multipath signals<\/td>\n<td data-col-size=\"lg\">Received signal strength when no dominant path<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Optical scattering<\/td>\n<td data-col-size=\"lg\">Intensity of scattered light<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div><\/div>\n<\/div>\n<\/div>\n<p dir=\"auto\"><strong>Most famous appearance<\/strong> \u2014 <strong>Rayleigh fading<\/strong> in wireless communications<\/p>\n<p dir=\"auto\">In mobile communication, the received signal amplitude often follows Rayleigh when there is <strong>no line-of-sight<\/strong> path and many small reflections arrive from different directions.<\/p>\n<h3 dir=\"auto\">6. Realistic code patterns you will actually write<\/h3>\n<p dir=\"auto\"><strong>Pattern 1 \u2013 Simulate Rayleigh fading channel coefficients<\/strong><\/p>\n<div dir=\"auto\">\n<div data-testid=\"code-block\">\n<div>\n<div>Python<\/div>\n<div>\n<pre tabindex=\"0\"><code># Wireless channel \u2013 Rayleigh fading with average power = 1\r\nsigma = 1 \/ np.sqrt(2)          # because Var = 2\u03c3\u00b2 = 1 \u2192 \u03c3 = 1\/\u221a2\r\n\r\nchannel_real = np.random.normal(0, sigma, 100000)\r\nchannel_imag = np.random.normal(0, sigma, 100000)\r\nchannel_amplitude = np.sqrt(channel_real**2 + channel_imag**2)\r\n\r\nprint(\"Average amplitude:\", channel_amplitude.mean().round(4))  # \u2248 1.253\r\nprint(\"Theoretical mean:\", sigma * np.sqrt(np.pi).round(4))     # \u2248 1.253<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p dir=\"auto\"><strong>Pattern 2 \u2013 Simulate signal + Rayleigh fading + noise<\/strong><\/p>\n<div dir=\"auto\">\n<div data-testid=\"code-block\">\n<div>\n<div>Python<\/div>\n<div>\n<pre tabindex=\"0\"><code># Transmitted signal amplitude = 2.0\r\nsignal = 2.0\r\n\r\n# Rayleigh fading\r\nh = stats.rayleigh.rvs(scale=1, size=50000)\r\n\r\n# Additive Gaussian noise (SNR simulation)\r\nnoise_power = 0.1\r\nnoise = np.random.normal(0, np.sqrt(noise_power), 50000)\r\n\r\nreceived = h * signal + noise\r\n\r\nreceived_amplitude = np.abs(received)\r\n\r\nsns.histplot(received_amplitude, bins=80, stat=\"density\", kde=True,\r\n             color=\"teal\", alpha=0.7)\r\nplt.title(\"Received signal amplitude (Rayleigh fading + noise)\")\r\nplt.xlabel(\"Amplitude\")\r\nplt.show()<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p dir=\"auto\"><strong>Pattern 3 \u2013 Probability that amplitude exceeds a threshold<\/strong><\/p>\n<div dir=\"auto\">\n<div data-testid=\"code-block\">\n<div>\n<div>Python<\/div>\n<div>\n<pre tabindex=\"0\"><code>sigma = 1.5\r\nthreshold = 4.0\r\n\r\n# P(R &gt; threshold) = exp(-threshold\u00b2 \/ (2\u03c3\u00b2))\r\ntheoretical_prob = np.exp(-threshold**2 \/ (2 * sigma**2))\r\n\r\n# Simulate\r\nsamples = stats.rayleigh.rvs(scale=sigma, size=100000)\r\nempirical_prob = np.mean(samples &gt; threshold)\r\n\r\nprint(f\"Theoretical P(R &gt; {threshold}) = {theoretical_prob:.5f}\")\r\nprint(f\"Empirical P(R &gt; {threshold})    = {empirical_prob:.5f}\")<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3 dir=\"auto\">Summary \u2013 Rayleigh Distribution Quick Reference<\/h3>\n<div>\n<div dir=\"auto\">\n<table dir=\"auto\">\n<thead>\n<tr>\n<th data-col-size=\"md\">Property<\/th>\n<th data-col-size=\"lg\">Value \/ Formula<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td data-col-size=\"md\">Shape<\/td>\n<td data-col-size=\"lg\">Right-skewed, peak at \u03c3, no left tail<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Defined by<\/td>\n<td data-col-size=\"lg\">scale parameter \u03c3 (\u03c3 &gt; 0)<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Mean<\/td>\n<td data-col-size=\"lg\">\u03c3 \u00d7 \u221a(\u03c0\/2) \u2248 1.2533 \u03c3<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Variance<\/td>\n<td data-col-size=\"lg\">(4\u2212\u03c0)\/2 \u00d7 \u03c3\u00b2 \u2248 0.4292 \u03c3\u00b2<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Mode<\/td>\n<td data-col-size=\"lg\">\u03c3 (peak exactly at \u03c3)<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Median<\/td>\n<td data-col-size=\"lg\">\u03c3 \u00d7 \u221a(ln 2) \u2248 1.177 \u03c3<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Support<\/td>\n<td data-col-size=\"lg\">x \u2265 0<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">PDF<\/td>\n<td data-col-size=\"lg\">(x \/ \u03c3\u00b2) exp(\u2212x\u00b2 \/ (2\u03c3\u00b2)) for x \u2265 0<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">CDF<\/td>\n<td data-col-size=\"lg\">1 \u2212 exp(\u2212x\u00b2 \/ (2\u03c3\u00b2))<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">NumPy \/ SciPy<\/td>\n<td data-col-size=\"lg\">scipy.stats.rayleigh.rvs(scale=\u03c3, size=&#8230;)<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Most common use cases<\/td>\n<td data-col-size=\"lg\">Signal envelope, fading channels, radar cross-section, magnitude of 2D Gaussian<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div><\/div>\n<\/div>\n<\/div>\n<h3 dir=\"auto\">Final teacher messages<\/h3>\n<ol dir=\"auto\">\n<li><strong>Whenever you are looking at the magnitude \/ amplitude \/ envelope of a signal<\/strong> that comes from two independent Gaussian components \u2192 think Rayleigh.<\/li>\n<li><strong>Rayleigh = special case of Rice distribution<\/strong> when there is no line-of-sight component (non-centrality = 0).<\/li>\n<li><strong>Rayleigh fading<\/strong> is one of the most famous applications \u2014 you will see it constantly if you work in wireless communications or signal processing.<\/li>\n<\/ol>\n<p dir=\"auto\">Would you like to continue with any of these next?<\/p>\n<ul dir=\"auto\">\n<li>Rayleigh vs Rician distribution (when there is a dominant path)<\/li>\n<li>How to estimate \u03c3 from real data<\/li>\n<li>Rayleigh fading simulation for communication systems<\/li>\n<li>Realistic mini-project: simulate signal strength + fading + noise<\/li>\n<li>Comparing Rayleigh with exponential, chi-square, gamma<\/li>\n<\/ul>\n<p dir=\"auto\">Just tell me what you want to explore next! \ud83d\ude0a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. What is the Rayleigh distribution really? The Rayleigh distribution describes the magnitude (absolute value \/ length) of a two-dimensional random vector whose components are independent normal random variables with zero mean and equal&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[],"class_list":["post-2523","post","type-post","status-publish","format-standard","hentry","category-numpy"],"_links":{"self":[{"href":"https:\/\/demo.materiamedica.net\/demo6\/wp-json\/wp\/v2\/posts\/2523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demo.materiamedica.net\/demo6\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demo.materiamedica.net\/demo6\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demo.materiamedica.net\/demo6\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demo.materiamedica.net\/demo6\/wp-json\/wp\/v2\/comments?post=2523"}],"version-history":[{"count":1,"href":"https:\/\/demo.materiamedica.net\/demo6\/wp-json\/wp\/v2\/posts\/2523\/revisions"}],"predecessor-version":[{"id":2524,"href":"https:\/\/demo.materiamedica.net\/demo6\/wp-json\/wp\/v2\/posts\/2523\/revisions\/2524"}],"wp:attachment":[{"href":"https:\/\/demo.materiamedica.net\/demo6\/wp-json\/wp\/v2\/media?parent=2523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demo.materiamedica.net\/demo6\/wp-json\/wp\/v2\/categories?post=2523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demo.materiamedica.net\/demo6\/wp-json\/wp\/v2\/tags?post=2523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}