Probability Density Functions of Random Signals: Uniform, Gaussian and Rayleigh
Learn the probability density function of random signals. Compare uniform, Gaussian and Rayleigh densities, their mean and variance, and plot a PDF in MATLAB.
Why random signals need statistics
Noise, fading and the message of a real user cannot be written as a formula of time. They are random signals. We cannot predict one value, but we can describe how likely each value is. The probability density function, PDF, does this. For a random value x, the area under the PDF between two numbers is the probability that x falls between them.
P(a < x < b) = ∫ f(x) dx from a to b ∫ f(x) dx = 1 over all x
The total area is always 1, because the value must be somewhere. A tall PDF means a narrow spread of values. A wide, low one means a large spread. The mean is the centre of mass of the curve and the variance measures its spread.
The uniform density
A uniform value is equally likely anywhere between a lower limit a and an upper limit b.
f(x) = 1 / (b − a) for a ≤ x ≤ b, zero elsewhere mean = (a + b) / 2, variance = (b − a)² / 12
Example: a value uniform between 0 and 1 V has a mean of 0.5 V and a variance of 1/12, which is 0.083 V². This density describes the rounding error of an analog to digital converter. If the step size is Δ, the error is uniform over −Δ/2 to +Δ/2, so the noise power is Δ² / 12.
The Gaussian density
The Gaussian, or normal, density is the bell curve. It describes thermal noise, and any value that is the sum of many small independent effects. This follows from the central limit theorem.
f(x) = 1 / (σ √(2π)) · exp( − (x − μ)² / (2 σ²) )
- The mean μ is where the peak sits. The standard deviation σ sets the width.
- About 68 percent of values fall within ±1 σ of the mean, 95 percent within ±2 σ and 99.7 percent within ±3 σ.
- For zero mean noise, σ² is the noise power, and σ is the rms voltage.
The chance that Gaussian noise goes above a level a is called Q(a/σ). A digital receiver makes a bit error when noise pushes the signal across the threshold, so bit error rates are Q function values.
The Rayleigh density
The Rayleigh density describes a magnitude that can never be negative. It occurs when you take the length of a vector whose two parts are independent zero mean Gaussian values with the same σ. The envelope of narrowband Gaussian noise follows it, and so does the signal strength in a radio link without a direct path, which makes it the standard model of fading.
f(r) = (r / σ²) exp( − r² / (2 σ²) ) for r ≥ 0 mean = σ √(π/2) = 1.253 σ, variance = (4 − π) σ² / 2 = 0.429 σ²
The peak, called the mode, is at r = σ. Unlike the Gaussian, the Rayleigh density is not symmetric. It rises from zero, peaks at σ, and has a long tail to the right.
Plotting a PDF in MATLAB
Generate many samples, form a histogram and scale it so that its area is 1. Compare it with the formula.
N = 1e5; g = randn(1, N); % Gaussian, mean 0, sigma 1 r = sqrt(randn(1,N).^2 + randn(1,N).^2); % Rayleigh, sigma 1 histogram(r, 60, 'Normalization', 'pdf'); hold on x = linspace(0, 5, 200); plot(x, x .* exp(-x.^2/2))
With the option pdf the histogram heights are scaled so the area is 1, so the bars follow the formula. With a count of 100 000 samples the match is close. With 100 samples the bars are very rough.
Reading the three shapes
A quick check on a measured signal: plot its histogram, then look at the shape. Flat suggests uniform, a symmetric bell suggests Gaussian, and a hump with a long right tail that starts at zero suggests Rayleigh.
| Density | Range | Shape | Typical use |
|---|---|---|---|
| Uniform | a to b | flat box | rounding error, random phase |
| Gaussian | all values | symmetric bell | thermal noise |
| Rayleigh | zero and above | skewed hump | noise envelope, fading |
Checking the mean and variance
The formulas for the mean and variance can be checked on generated data. The result gets closer to the formula as the number of samples grows.
r = sqrt(randn(1,1e5).^2 + randn(1,1e5).^2); mean(r) % close to 1.2533 var(r) % close to 0.4292 u = rand(1,1e5); mean(u), var(u) % close to 0.5 and 0.0833
The error of a sample mean is about σ / √N. With 100 000 samples and σ near 0.65 the error is about 0.002, so the mean of r agrees with 1.2533 to the second decimal place. With 100 samples the error is about 0.07 and the match is poor. The sum of 12 uniform values minus 6 is close to a Gaussian value with variance 1, a quick way to see the central limit theorem at work.
Try it in the virtual lab
SinBench has free 3D benches and interactive demos for this topic. Open one to try the ideas above with real instruments, no sign up needed.
Questions and answers
What is a probability density function?
It is a curve that shows how likely each value of a random quantity is. The area under it between two values is the probability of falling between them, and the total area is 1.
Why is thermal noise Gaussian?
It is the sum of the effects of a very large number of electrons moving randomly. The central limit theorem says such a sum is Gaussian.
Where does the Rayleigh density come from?
It is the density of the length of a vector made of two independent zero mean Gaussian values with equal variance. It models the envelope of noise and radio fading.
How do I plot a PDF from data in MATLAB?
Use histogram(x, 'Normalization', 'pdf'). It scales the bars so the total area is 1, so they can be compared with the PDF formula.
Related topics
ASK and FSK: Digital Modulation of a Carrier
Learn amplitude shift keying and frequency shift keying: waveforms, bandwidth, detection, and error rates against Eb/N0, with a short MATLAB example.
Communication SystemsFFT in MATLAB: Frequency Axis, fftshift and Spectral Leakage
Use the FFT in MATLAB correctly: build the frequency axis, scale the amplitude, apply fftshift, and understand spectral leakage, windows and zero padding.
Communication SystemsAmplitude Modulation and the Modulation Index
Learn how amplitude modulation works: the AM equation, the modulation index from an oscilloscope picture, sidebands, bandwidth, power and overmodulation.