Communication Systems · Lab 12 · Random Signals and the Probability Density FunctionAll labs

Noise is random. Its shape is not.

Ten minutes of reading. Move the sliders, then try the same commands in MATLAB and compare.

01

Why randomness

A real channel adds noise and makes the received signal fade. Neither can be predicted sample by sample, but both follow a known distribution. To test a receiver in MATLAB we generate random numbers with that distribution and add them to the signal: Gaussian numbers for thermal noise, Rayleigh numbers for the fading of a mobile radio link without line of sight.

Pseudorandom. MATLAB's numbers come from an algorithm (the Mersenne Twister). They look random, but the same seed always gives the same numbers, which is what makes a simulation repeatable.
02

pdf and PDF

pdff(x)how likely a value near x is; area under it is 1
PDF (CDF)F(x) = P(X ≤ x) = ∫−∞x f(u)durises from 0 to 1
IntervalP(a < X ≤ b) = F(b) − F(a)the area of f between a and b

The probability density function f(x) gives the likelihood of a value near x; in a receiver x can be the received voltage. The probability that X falls in an interval is the area under f(x) over that interval. The probability distribution function F(x), also called the cumulative distribution function, adds the area up to x. A histogram of many random numbers, scaled so its area is 1, approaches the pdf.

03

Random numbers in MATLAB

Uniformrand(M,N)values in (0, 1)
Normalrandn(M,N)mean 0, standard deviation 1
Repeatablerng('default'), s = rng, rng(s)reset, save, restore

To get numbers in an interval, scale rand: a + (b − a)·rand(1,100) lies between a and b, and hist(N,10) counts the numbers in ten equal bins. With only 100 numbers the bars are uneven; raise the count and every bar approaches n/10, the flat shape of the uniform pdf. After rng('default') (and right after MATLAB starts) the first five values of rand are 0.8147, 0.9058, 0.127, 0.9134, 0.6324, and the first five of randn are 0.5377, 1.8339, -2.2588, 0.8622, 0.3188. If you save the generator with s = rng and restore it later with rng(s), the next numbers repeat exactly.

Asking for the interval. A script can ask for the two ends with input; type 1 and 5 to get numbers between 1 and 5. A script that should run without questions sets the two values in the code instead. hist is an older function; histogram(N,10) draws the same counts.
04

The Gaussian distribution

pdff(x) = e−(x−µ)²/2σ² / (σ√(2π))the bell curve
Peak1/(σ√(2π))0.3989 for the standard normal
Spread68 % within µ ± σ95 % within µ ± 2σ

µ is the mean (also the median and the mode) and σ the standard deviation; the variance is σ². The standard normal (µ = 0, σ = 1) can be drawn with pdf('Normal',x,0,1), whose peak is 0.3989 at x = 0. Thermal noise in every receiver is Gaussian, because it is the sum of a huge number of tiny independent effects (the central limit theorem).

05

The Rayleigh distribution

pdff(x) = (x/B²)·e−x²/2B², x ≥ 0raylpdf(x,B)
Peakat x = B, f = e−1/2/B0.6065 for B = 1
OriginR = √(X² + Y²)X, Y Gaussian, mean 0, σ = B

The length of a vector whose two components are independent zero mean Gaussians with the same σ = B follows the Rayleigh distribution: the wind speed from its two components, or the magnitude of a complex number with Gaussian real and imaginary parts. The histogram in the demo is made exactly that way, from pairs of Gaussian numbers, and it follows raylpdf.

Property names in plot calls. A name such as 'fontsize' in ylabel or xlabel must be spelled exactly, with no space at the start or the end. A stray space, as in 'fontsize ', makes recent MATLAB versions stop with an error about an unknown property. Write ylabel('pdf --->','fontsize',12). Some functions are more forgiving: pdf accepts 'Normal ' with a trailing space, but it is cleaner not to rely on that.
06

Rayleigh fading

In a city a mobile phone rarely sees the base station directly. The signal arrives along many reflected paths with random phases, and their sum is a complex Gaussian: its magnitude, the received amplitude, is Rayleigh distributed and drops deep into fades several times per wavelength of movement. Rayleigh fading is the standard model when there is no line of sight (urban streets, the ionosphere and the troposphere). With a strong direct path the amplitude follows the Rician distribution instead.

07

Check yourself

Q1Why does communication engineering need probability density?

It describes quantities that cannot be predicted exactly, such as noise voltage and fading amplitude. With the pdf of the noise we can find the probability of a bit error, design the decision threshold, and simulate a channel by generating random numbers with the same distribution.

Q2What does a probability density function tell you?

It is a function f(x) ≥ 0 whose area over an interval is the probability that the random variable falls in that interval; its total area is 1. Its integral up to x is the probability distribution (cumulative) function F(x) = P(X ≤ x).

Q3What is the formula of the Gaussian pdf?

f(x) = (1/(σ√(2π)))·exp(−(x − µ)²/(2σ²)), where µ is the mean and σ the standard deviation.

Q4How do µ and σ shape the Gaussian curve?

The curve is a symmetric bell centred on the mean µ. σ sets its width: about 68 % of the values lie within µ ± σ, 95 % within µ ± 2σ and 99.7 % within µ ± 3σ. A larger σ gives a wider, lower curve because the area stays 1. With µ = 0 and σ = 1 it is the standard normal distribution.

Q5What is the standard deviation?

The square root of the variance: σ = √(E[(X − µ)²]). It measures how far the values spread from the mean, in the same units as the values. For noise, σ² is the noise power.

Q6Where is the Rayleigh distribution used?

It models the amplitude of a signal that reaches the receiver along many paths with no line of sight (Rayleigh fading in mobile radio), and any magnitude of a vector with two independent zero mean Gaussian components, such as wind speed.

Q7What is the formula of the Rayleigh pdf?

f(x) = (x/B²)·exp(−x²/(2B²)) for x ≥ 0 and 0 for x < 0. B is the σ of each Gaussian component. The pdf starts at 0, peaks at x = B with height e^(−1/2)/B, and has a long tail; its mean is B√(π/2).

Q8How does MATLAB generate random numbers?

rand gives uniform numbers in (0, 1), randn standard normal numbers, randi random integers, and random or raylrnd numbers of other distributions. They are pseudorandom, from the Mersenne Twister by default; rng sets the seed (rng('default') resets it, s = rng saves it and rng(s) restores it) so a result can be repeated.