random processes and stochastic control – part 1 of 2 ... · random processes and stochastic...
TRANSCRIPT
' Gdansk Universityof Technology
Random Processes and Stochastic
Control – Part 1 of 2
Exercises
by
Maciej Niedzwiecki
Gdansk University of Technology
Departament of Automatic Control
Gdansk, Poland
Exercise 1
Using MATLAB generate and plot the sequence of 100consecutive realizations of 3 random variables: A withuniform PDF, B with Gaussian PDF and C with LaplacePDF. All random variables should have the same mean:
mA = mB = mC = 2
and the same variance:
σ2A = σ2
B = σ2C = 2
Use the same scale on the x and y axes
x ∈ [1, 100], y ∈ [−3, 7]
Exercise 2
Using MATLAB generate and plot the sequence of 100consecutive realizations of the Cauchy random variable D ∼C(2, 1).
Exercise 3
The mean and variance of a random variable X can beestimated using the following relationships
mX(N) =1N
N∑i=1
xi
σ2X(N) =
1N
N∑i=1
[xi − mX(N)]2
Estimate the mean and the variance of the random variablesA,B,C and D defined in Exercises 1 and 2, based on N =100, 1,000, 10,000 and 100,000 samples.
Exercise 4
Using MATLAB plot normalized histograms obtained for10,000 samples of random variables C and D (defined inexercises 1 and 2) and compare them with the correspondingPDF plots. In both cases divide the interval [-3, 7] (subsetof the observation space) into 20 bins of equal width 0.5.
Exercise 5
Write MATLAB procedure generating samples of a randomvariable E with the following PDF
a) pE(e) =
0.50 e ∈ [−1, 0]0.25 e ∈ (0, 2]0 elsewhere
b) pE(e) =
−e e ∈ [−1, 0]0.5 e ∈ (0, 1]0 elsewhere
Evaluate the mean, median and standard deviation of E.
∫ 0
−1
epE(e)de = 0.5e2
2
∣∣∣∣0
−1
= −14
∫ 2
0
epE(e)de = 0.25e2
2
∣∣∣∣2
0
=12
∫ 0
−1
e2pE(e)de = 0.5e3
3
∣∣∣∣0
−1
= −16
∫ 2
0
e2pE(e)de = 0.25e3
3
∣∣∣∣2
0
=23
mX =12− 1
4=
14
σ2X =
16
+23−
(14
)2
=3748
αX = 0
Exercise 6
Denote by E1, . . . , E16 the sequence of 16 independentrandom variables with PDF specified in Exercise 5. Let
F =14
16∑i=1
Ei − mE
σE
Using MATLAB plot the normalized histogram obtained for10,000 samples of F . Compare it with an appropriatelyscaled plot of a standard Gaussian PDF N (0, 1). Dividethe interval [-5, 5] (subset of the observation space) into 20bins of equal width 0.5.
Exercise 7
Let X be a random variable that is uniformly distributedover the interval (1,100). Form a new random variable Yby rounding X to the nearest integer. In MATLAB code,this could be represented by Y = round(X). Finally, formthe roundoff error variable according to Z = X − Y . UsingMATLAB generate 10,000 realizations of Z and estimateits mean and variance. Based on the available data createa normalized histogram. Find the analytical model thatseems to fit your estimated PDF.
Exercise 8
Which of the following mathematical functions could be thecumulative distribution function of some random variable?
1. FX(x) = 12 + 1
πtan−1(x)
2. FX(x) = [1 − e−x] 1(x)
3. FX(x) = e−x2
4. FX(x) = x21(x)
Note: 1(x) is the unit step function.
Exercise 9
Suppose a random variable has a cumulative distributionfunction given by FX(x) = [1 − e−x] 1(x). Find thefollowing quantities:
1. P (X > 5)
2. P (X < 5)
3. P (3 < X < 7)
4. P (X > 5|X < 7)
Exercise 10
Suppose a random variable has a cumulative distributionfunction given by
FX(x) =
0 x ≤ 00.04x 0 < x ≤ 5
0.6 + 0.04x 5 < x ≤ 101 x > 10
Find the following quantities:
1. P (X > 5)
2. P (X < 5)
3. P (3 < X < 7)
4. P (X > 5|X < 7)
Exercise 11
Which of the following are valid probability densityfunctions?
1. pX(x) = e−x1(x)
2. pX(x) = e−|x|
3. pX(x) ={
34(x
2 − 1) |x| < 20 otherwise
4. pX(x) = 2xe−x21(x)
Exercise 12
The conditional cumulative distribution function of randomvariable X , conditioned on the event A having occurred is
FX|A(x) = P (X ≤ x|A) =P (X ≤ x, A)
P (A)
(assuming that P (A) �= 0).
Suppose that X ∼ U(0, 1). Find the mathematicalexpression for FX|X<1/2(x).
Exercise 13
Consider the Laplace random variable with a PDF given by
pX(x) =b
2exp(−b|x|)
Evaluate the mean, the variance, the coefficient of skewnessand the coefficient of kurtosis of X .
Note: ∫xneaxdx =
1a
xneax − n
a
∫xn−1eaxdx
Exercise 14
Consider two independent normally distributed randomvariables
X ∼ N (0, 1), Z ∼ N (0, 1)
and letY = aX + bZ, a, b ∈ R
Determine the coefficients a and b in such a way thatY ∼ N (0, 1) and ρXY takes any prescribed value from[−1, 1].
Using MATLAB generate 100 realizations of the pair (X, Y )for ρXY = 0, ρXY = 0.5, ρXY = −0.5, ρXY = 0.9,ρXY = −0.9, ρXY = 1 and ρXY = −1.
Display the obtained results using scatter plots.
Facts about matrices
Fact 1
Given a square matrix An×n, an eigenvalue λ and itsassociated eigenvector v are a pair obeying the relation
Av = λv
The eigenvalues λ1, . . . , λn of A are the roots of thecharacteristic polynomial of A
det(A− λI)
For a positive definite matrix A it holds that λ1, . . . , λn > 0,i.e., all eigenvalues are positive real.
Fact 2
Let A be a matrix with linearly independent eigenvectorsv1, . . . ,vn. Then A can be factorized as follows
A = VΛV−1
where Λn×n = diag{λ1, . . . , λn} and Vn×n = [v1| . . . |vn].
Facts about matrices
Fact 3
Let A = AT be a real symmetric matrix. Such matrix hasn linearly independent real eigenvectors. Moreover, theseeigenvectors can be chosen such that they are orthogonalto each other and have norm one
wTi wj = 0, ∀i �= j
wTi wi = ||wi||2 = 1, ∀i
A real symmetrix matrix A can be decomposed as
A = WΛWT
where W is an orthogonal matrix: Wn×n = [w1| . . . |wn],WWT = WTW = I.
The eigenvectors wi can be obtained by normalizing theeigenvectors vi
wi =vi
||vi||2 , i = 1, . . . , n
Exercise 15
Consider a vector random variable X = [X1, X2]T with themean and covariance matrix given by
mX =[
34
], ΣX =
[5 44 5
]
1. Perform eigendecomposition of the matrix ΣX
ΣX = WΛWT
where Λ is a diagonal matrix made up of eigenvalues of ΣX
and W is an orthogonal matrix.
Sketch the covariance ellipse of X. What is the correlationcoefficient of X1 and X2?
2. Suppose that Z = [Z1, Z2]T is made up of twouncorrelated random variables with zero mean and unitvariance. Consider the following linear transformation
Y = WΛ1/2Z
where W and Λ are the matrices determined in point 1above. Show that
ΣY = ΣX.
3. Use a linear transformation, defined in point 2, togenerate two-dimensional Gaussian random variable X withthe mean and covariance matrix specified above. Create ascatter plot based on 200 realizations of X.
Exercise 16
Consider a zero-mean vector random variable X withcovariance matrix
ΣX = E[XXT] = WΛWT
where Λ is a diagonal matrix made up of eigenvalues of ΣX
and W is an orthogonal matrix.
LetY = WΛ−1/2WTX
Show thatΣY = I
i.e., Y is the vector random variable made up of uncorrelatedcomponents.
Project 1
Record and mix signals obtained from two independentspeech sources (30 second long recordings, 2 linear mixtureswith different mixing coefficients).
Perform blind source separation using the FastICAalgorithm:
1. Center the data to make its mean zero.
2. Whiten the data to obtain uncorrelated mixture signals.
3. Initialize w0 = [w1,0, w2,0]T, ||w0|| = 1 (e.g. randomly)
4. Perform an iteration of a one-source extraction algorithm
wi = avg{z(t)
[wT
i−1z(t)]3} − 3wi−1
where z(t) = [z1(t), z2(t)]T denotes the vector of whitenedmixture signals and avg(·) denotes time averaging
avg{x(t)} =1N
N∑t=1
x(t)
5. Normalize wi by dividing it by its norm
wi =wi
||wi||
6. Determine a unit-norm vector vi orthogonal to wi.
wTi vi = 0, ||vi|| = 1
7. Display and listen to the current results of sourceseparation
[x1(t)x2(t)
]=
[wT
i
vTi
] [z1(t)z2(t)
], t = 1, . . . , N
8. If wTi wi−1 is not close enough to 1, go back to step 4.
Otherwise stop.
Literature: A. Hyvarinen, E. Oja. “A fast fixed-pointalgorithm for independent component analysis”, NeuralComputation, vol. 9, pp. 1483-1492, 1997.
A special bonus will be granted for writing a procedure thatextracts n > 2 source signals from n mixtures.
Project 2
Create a noisy audio recording (add artificially generatednoise to a clean music or speech signal). The first secondof the recording should contain noise only. Then denoiserecording using the method of spectral subtraction.
Exercise 17
Consider a sinusoid with a random frequency
X(t) = cos(2πft)
where f is a random variable uniformly distributed over theinterval [0, f0].
1. Show that the theoretical mean function of X(t) is givenby
mX(t) = E[X(t)] =sin(2πf0t)
2πf0t
2. Estimate the mean function of X(t) using ensembleaveraging in the case where f0 = 0.01
mX(t) =1
1000
1000∑i=1
X(t, ξi), t = −300, . . . , 300
3. Plot the obtained estimates and compare them with thetheoretical mean function.
Exercise 18
Generate 400 samples of the first-order autoregressiveprocess governed by
Y (t) = 0.99Y (t − 1) + X(t), t = 1, 2, . . .
where Y (0) = 0 and X(t) denotes Gaussian white noisewith mean 0 and variance σ2
X = 1.
1. Depict on one plot 100 realizations of Y (t), t ∈ [1, 400].Starting from what time instant the process can beregarded as wide-sense stationary?
2. Determine analytically the mean function of Y (t) for anyinitial condition Y (0) = y0.
3. Estimate the steady-state autocorrelation function ofY (t) using time averaging
RX(τ) =1
100
300∑t=201
Y (t)Y (t + τ), τ = 0, . . . , 100
4. Estimate the steady-state autocorrelation function ofY (t) using ensemble averaging
RX(τ) =1
100
100∑i=1
Y (t, ξi)Y (t + τ, ξi)
t = 201, τ = 0, . . . , 100
5. Plot the obtained estimates and compare them with thetheoretical autocorrelation function
RX(τ) =(0.99)|τ |
1 − (0.99)2
Exercise 19
Consider random telegraph signal governed by
X(t) ∈ {−1, 1}
P (X(t + 1) = 1|X(t) = 1) = 0.99
P (X(t + 1) = −1|X(t) = 1) = 0.1
P (X(t + 1) = 1|X(t) = −1) = 0.1
P (X(t + 1) = −1|X(t) = −1) = 0.99
t = 1, . . . , 200
P (X(0) = 1) = P (X(0) = −1) = 0.5
Estimate and plot RX(τ), τ = 0, . . . , 100. To obtain theestimates use a) time averaging b) ensemble averaging.Plot and compare the obtained results.
Exercise 20
Consider a zero-mean Gausiian white noise X(t) withvariance σ2
X = 1.
1. Evaluate spectral density function SX(ω) of this process.
2. Compute and plot periodogram-based estimates ofSX(ω) using datasets consisting of N = 100, 1000 and10000 samples
PX(ωi, N) =1N
∣∣∣∣∣N∑
t=1
X(t)e−jωit
∣∣∣∣∣2
ωi = 2πi/100 , i = −50, . . . , 50
Compare the obtained results with the true spectraldensity function of X(t).
3. Compute time-averaged periodogram-based estimates
PX(ωi, N) =1M
M∑j=1
P jX(ωi, N)
ωi = 2πi/100 , i = −50, . . . , 50
where P jX(ωi, N) denotes periodogram obtained for the
j-th segment of X(t) of length N . Plot the resultsobtained for N = 100.
Exercise 21
Y (t) is a random process observed at the output of thesecond-order filter
H(z−1) =1
1 + a1z−1 + a2z−2
excited with white Gaussian noise X(t) ∼ N (0, 1) underzero initial conditions. The poles of the filter are given inthe form
z1 = rejφ, z1 = re−jφ
whereA) r = 0.9, φ = π/100B) r = 0.9, φ = π/10C) r = 0.99, φ = π/100D) r = 0.99, φ = π/10
1. Compute the coefficients a1 and a2 in each of the fourcases indicated above.
2. Plot the amplitude characteristics of H(z−1)
A(ωi) =∣∣H(e−jωi)
∣∣ , ωi = πi/1000, i = 1, . . . , 1000
What is rhe influence of r and φ on the shape of theamplitude characteristic of H(z−1) ?