Lecture 5 · Communications Engineering · University of Klagenfurt, 2023
Lecture 5 of 6
From Communications Engineering at the University of Klagenfurt, first taught in 2020: this is the edition of winter 2023, so some of it may be a little dated. All lectures.
01
A random variable (r.v.) X(\omega) is a real-valued function defined on a probability space \Omega:
X(\omega):\Omega\to\mathbb{R}
It maps events, random phenomena in \Omega, into real outcomes. It is fully described by its cumulative distribution function (CDF):
F_X(a):=P[X\le a]
Properties:
If F_X(a) is continuous, the random variable is continuous, and the CDF can be written as
F_X(a)=\int_{-\infty}^{a}f_X(b)\,db
where f_X(a)=\dfrac{dF_X(a)}{da} is the probability density function (PDF). Properties:
If F_X(a) is piecewise constant, with a countable number of jumps, the random variable is discrete: X takes values in an alphabet A=\{\alpha_1,\alpha_2,\dots,\alpha_n\}.
F_X(a)=\sum_{\alpha_i\in A}p_X(\alpha_i)\cdot1(a-\alpha_i)
where p_X(\alpha_i)=P[X=\alpha_i]=F_X(\alpha_i)-F_X(\alpha_i^-) is the probability mass function (PMF). The PDF becomes a train of impulses:
f_X(a)=\sum_{\alpha_i\in A}p_X(\alpha_i)\cdot\delta(a-\alpha_i)
| continuous | discrete | |
|---|---|---|
| mean | E[X]=m_X=\displaystyle\int_{-\infty}^{+\infty}a\,f_X(a)\,da | E[X]=m_X=\displaystyle\sum_{\alpha_i\in A}\alpha_i\,p_X(\alpha_i) |
| power | E[X^2]=M_X=\displaystyle\int_{-\infty}^{+\infty}a^2f_X(a)\,da | E[X^2]=M_X=\displaystyle\sum_{\alpha_i\in A}\alpha_i^2\,p_X(\alpha_i) |
| variance | \sigma_X^2=\displaystyle\int_{-\infty}^{+\infty}(a-m_X)^2f_X(a)\,da | \sigma_X^2=\displaystyle\sum_{\alpha_i\in A}(\alpha_i-m_X)^2\,p_X(\alpha_i) |
with \sigma_X^2=E\left[(X-m_X)^2\right]=M_X-m_X^2 in both cases.
Expectation theorem. For Y=g(X):
E[Y]=E[g(X)]=\int_{-\infty}^{+\infty}g(a)\,f_X(a)\,da\qquad\text{or}\qquad E[Y]=\sum_{\alpha_i\in A}g(\alpha_i)\,p_X(\alpha_i)
1. f_X\ge0, and with y=\frac{x-\mu}{\sigma}, dx=\sigma\,dy:
\int_{-\infty}^{+\infty}f_X(x)\,dx=\int_{-\infty}^{+\infty}\frac{1}{\sqrt{2\pi}}e^{-\frac{y^2}{2}}dy=1,\qquad E[X]=\int_{-\infty}^{+\infty}\frac{\sigma y+\mu}{\sqrt{2\pi}}e^{-\frac{y^2}{2}}dy=0+\mu
the first part being odd. For the variance, by parts: E\left[(X-\mu)^2\right]=\sigma^2\int\frac{y^2}{\sqrt{2\pi}}e^{-\frac{y^2}{2}}dy=\sigma^2.
2. Standardize, Z=\frac{X-\mu}{\sigma}\sim\mathcal{N}(0,1), with Q(z)=P[Z>z]:
P[153\le X\le203]=P[-3.03\le Z\le3.71]=1-Q(3.03)-Q(3.71)\approx0.9987\approx1-\frac{1}{1000}
All of n men meet it with probability p^n<\frac12, so n>\frac{\ln2}{-\ln p}\approx\frac{0.693}{10^{-3}}: about 693 men, using \ln(1+x)\approx x. The answer is very sensitive to rounding p: with p=0.99868, n=526.
3. f_\theta=\frac1\pi on \left(-\frac\pi2,\frac\pi2\right), so
E[X]=\int_{-\pi/2}^{\pi/2}\frac{\sin\vartheta}{\pi}\,d\vartheta=0,\qquad V[X]=E\left[\sin^2\theta\right]=\frac1\pi\int_{-\pi/2}^{\pi/2}\frac{1-\cos2\vartheta}{2}\,d\vartheta=\frac12
\sin is increasing on \left(-\frac\pi2,\frac\pi2\right), so for |x|<1
F_X(x)=P[\theta\le\arcsin x]=\frac1\pi\arcsin x+\frac12,\qquad f_X(x)=\frac{1}{\pi\sqrt{1-x^2}}
with F_X=0 for x\le-1, F_X=1 for x\ge1, and f_X=0 outside (-1,1).
1. E[X]=0\cdot(1-p)+1\cdot p=p,\qquad V[X]=E[X^2]-E^2[X]=p-p^2=p(1-p)
2. X=\sum_iZ_i, Z_i\sim\mathrm{Ber}(p) independent. One sequence with 5 heads has probability p^5(1-p)^5, and there are \binom{10}{5} of them: the binomial distribution,
P[X=5]=\binom{10}{5}p^5(1-p)^5=\frac{252}{1024}\approx0.246\ \text{ for a fair coin},\qquad p_{X,1000}(k)=\binom{1000}{k}p^k(1-p)^{1000-k}
For many trials, by the central limit theorem, X is approximately \mathcal{N}\left(1000p,\ 1000p(1-p)\right).
3. An error needs at least 2 of the 3 digits wrong:
P_e=\binom32q^2(1-q)+q^3=3q^2-2q^3=0.028,\qquad G=\frac{1-3q^2+2q^3}{1-q}=1+q-2q^2=1.08
G(q) is a downward parabola, G(0)=G\left(\frac12\right)=1, with its global maximum G=\frac98 at q=\frac14.
No saved run survives. What to expect: CoinTossing(10,5) returns 0.2461, and the gain plot is the parabola 1+q-2q^2, from 1 at q=0 up to 1.125 at q=0.25 and back to 1 at q=0.5.
02
A random process (r.p.) X(\omega,t) is a real (or complex) function of two variables:
X(\omega,t):\Omega\times\mathbb{R}\to\mathbb{R}
It can be read as a time series of random variables; stochastic signals are realizations of random processes. The complete statistical description is given by the joint CDF, for any N and any instants t_1,\dots,t_N:
F_X(\mathbf{a},\mathbf{t})=P\left[X(t_1)\le a_1,X(t_2)\le a_2,\dots,X(t_N)\le a_N\right]
The second-order description is given by the mean, the power and the autocorrelation:
m_X(t_1)=E[X(t_1)],\qquad M_X(t_1)=E\left[|X(t_1)|^2\right],\qquad r_{XX}(t_1,t_2)=E\left[X(t_1)\,X^*(t_2)\right]
Stationarity concerns the distributions of the random variables: in a stationary process
F_X(\mathbf{a},\mathbf{t})=F_X(\mathbf{a},\mathbf{t}+\tau)\quad\text{for any real }\tau
Ergodicity concerns averages: a process is ergodic if the statistical averages (mean, power and so on, also called ensemble averages) equal the time averages of a single realization.
For stationary processes, mean, power and variance do not depend on time, and the autocorrelation function (ACF) depends only on the difference \tau=t_2-t_1:
r_{XX}(\tau)=E\left[X(t)\,X^*(t+\tau)\right]
A wide sense stationary (WSS) process is stationary in mean, power and autocorrelation.
For a WSS process:
For two processes X(t) and Y(t), the cross-correlation is
r_{XY}(t_1,t_2)=E\left[X(t_1)\,Y^*(t_2)\right]
The Cauchy-Schwarz inequality for WSS processes: \ 0\le|r_{XY}(\tau)|^2\le M_X\cdot M_Y.
03
The power spectral density (PSD) R_X(f) of the process X(t) is the Fourier transform of its autocorrelation:
R_X(f)=\int_{-\infty}^{+\infty}r_{XX}(\tau)\,e^{-j2\pi f\tau}\,d\tau
%% PSD of a random process
rng default
Fs = 1000;
eps = 0.00001;
t = 0+eps:1/Fs:1-1/Fs;
x = sin(pi*t).^2./((pi*t).^2) + 0.1*randn(size(t));
N = length(x);
X = fft(x);
X = X(1:N/2+1);
psdx = (1/(Fs*N)) * abs(X).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
freq = 0:Fs/length(x):Fs/2;
plot(freq,10*log10(psdx))
%OR
figure
periodogram(x,rectwin(length(x)),length(x),Fs)
the periodogram, saved from the run
One realization: a \mathrm{sinc}^2 pulse plus white noise. The pulse puts its power near 0 Hz, the noise spreads a flat floor over the whole band, here about -50 dB/Hz, roughness included: a single periodogram is a noisy estimate.
The PSD is the fundamental tool to describe random processes through filters. Let x(t) be a WSS process and h(t) a real filter:
x(t) h(t) y(t)=\displaystyle\int_I x(\tau)h(t-\tau)\,d\tau
Then
X(t) is a white Gaussian noise process if it is a stationary Gaussian process with zero mean and a flat PSD,
R_X(f)=\frac{N_0}{2}\quad\text{for all }f
1. A and \varphi are independent, and E_A[A^2]=\frac{1}{2\pi}\int_{-\pi}^{\pi}a^2\,da=\frac{\pi^2}{3}. With \cos\alpha\cos\beta=\frac12\cos(\alpha+\beta)+\frac12\cos(\alpha-\beta), the term in 2\varphi averages to zero:
r_{XX}(\tau)=\frac{\pi^2}{6}\cos(2\pi f_0\tau)
R_X(f)=\frac{\pi^2}{12}\left[\delta(f-f_0)+\delta(f+f_0)\right]
2. H(f)=\mathrm{rect}(fT), so R_Y(f)=R_0\,\mathrm{triangle}(fT)\,\mathrm{rect}(fT), and y(t) is Gaussian with zero mean and
\sigma_Y^2=M_Y=\int_{-\frac{1}{2T}}^{\frac{1}{2T}}R_0\,\mathrm{triangle}(fT)\,df=\frac{3R_0}{4T}
P\left[|y(t)|<V_0\right]=1-2Q\left(V_0\sqrt{\frac{4T}{3R_0}}\right)
The sum is the output of the filter h(t)=\delta(t)+\delta\left(t-\frac{1}{2B}\right)+\delta\left(t-\frac1B\right), so y(t) is Gaussian with zero mean. Expanding the 9 products in E[y^2(t)], with r_{XX} even:
M_Y=3r_{XX}(0)+4r_{XX}\left(\tfrac{1}{2B}\right)+2r_{XX}\left(\tfrac1B\right)
From R_X(f)=R_0\,\mathrm{triangle}\left(\frac fB\right), r_{XX}(\tau)=R_0B\,\mathrm{sinc}^2(B\tau), with \mathrm{sinc}^2\left(\frac12\right)=\frac{4}{\pi^2} and \mathrm{sinc}^2(1)=0:
\sigma_Y^2=M_Y=R_0B\left(3+\frac{16}{\pi^2}\right)\approx4.62\,R_0B,\qquad P[y(t)>2]=Q\left(\frac{2}{\sigma_Y}\right)
Exercise 1, random variables. X has the PDF f_X(x)=\mathrm{triangle}\left(\frac xD\right).
Exercise 2, power spectral density. X(t) is a Gaussian process with zero mean and PSD R_X(f)=R_0\,\mathrm{triangle}\left(\frac fB\right), filtered by one of
h_1(t)=B\,\mathrm{sinc}(Bt),\qquad h_2(t)=B\,\mathrm{sinc}^2(Bt),\qquad h_3(t)=\frac{B}{1+(Bt)^2}
The area is D, so D=1; f_X is even, so E[X]=0 and V[X]=2\int_0^1x^2(1-x)\,dx=\frac16.
F_X(x)=\begin{cases}0&x<-1\\\frac{x^2}{2}+x+\frac12&-1\le x<0\\-\frac{x^2}{2}+x+\frac12&0\le x<1\\1&x\ge1\end{cases}
F_X(x)=P[G(U)\le x]=P\left[U\le G^{-1}(x)\right]=G^{-1}(x), so G=F_X^{-1}:
G(u)=\begin{cases}\sqrt{2u}-1&0\le u<\frac12\\1-\sqrt{2-2u}&\frac12\le u<1\end{cases}
H_1(f)=\mathrm{rect}\left(\frac fB\right), H_2(f)=\mathrm{triangle}\left(\frac fB\right), H_3(f)=\pi e^{-2\pi|f|/B}, and R_{Y_i}(f)=|H_i(f)|^2R_X(f):
R_{Y_1}=R_0\,\mathrm{triangle}\left(\tfrac fB\right)\mathrm{rect}\left(\tfrac fB\right),\qquad R_{Y_2}=R_0\,\mathrm{triangle}^3\left(\tfrac fB\right),\qquad R_{Y_3}=\pi^2R_0\,e^{-4\pi|f|/B}\,\mathrm{triangle}\left(\tfrac fB\right)
Integrating, the output powers are \frac34R_0B, \frac12R_0B and R_0B\left[\frac\pi2-\frac{1-e^{-4\pi}}{8}\right]\approx1.45\,R_0B: h_3 wins, as its gain at f=0 is \pi, against 1 for the other two.
To build X(t), filter white noise with PSD \frac{N_0}{2} through G(f)=\sqrt{\frac{2R_0}{N_0}\mathrm{triangle}\left(\frac fB\right)}: the output is Gaussian, with PSD |G(f)|^2\frac{N_0}{2}=R_0\,\mathrm{triangle}\left(\frac fB\right).
My solution sheet of 2023 covers exercise 1 only: this one is added for the web version, and no Matlab for it survives.
letizia.tech · Communications Engineering · University of Klagenfurt