Practice Exam 2021

(About 6 of the following problems)

Download Solutions to the problems 

Code to solutions:

Download prob1.m

Download prob2.m

Download problem6.m


1. System Identification Theory

a) Suppose that we would like to identify a model, where the true system is given by

LaTeX: y(t) = 0.4u(t-1) + 0.3u(t-2) + 0.2u(t-3) + 0.1u(t-4) + e(t)y(t)=0.4u(t1)+0.3u(t2)+0.2u(t3)+0.1u(t4)+e(t)y(t)=0.4u(t1)+0.3u(t2)+0.2u(t3)+0.1u(t4)+e(t)y(t)=0.4u(t1)+0.3u(t2)+0.2u(t3)+0.1u(t4)+e(t)

where LaTeX: e(t)\in N\left(0,1\right)e(t)N(0,1)e(t)e(t) is white noise with zero mean and unit variance. Suppose
that the input signal is a sinusoidal, LaTeX: u(t) = sin(\pi t/4)u(t)=sin(πt/4)u(t)=sin(πt/4)u(t)=sin(πt/4) and that you
estimate the parameters in a model of the form

LaTeX: y(t) = b_1u(t-1) + b_2u(t-2) + e(t)y(t)=b1u(t1)+b2u(t2)+e(t)y(t)=b1u(t1)+b2u(t2)+e(t)y(t)=b1u(t1)+b2u(t2)+e(t)

using a standard least squares prediction error method. What are the estimates of LaTeX: b_1b1b1b1 and LaTeX: b_2b2b2b2 when LaTeX: N \to \inftyNNN ?

b) In another scenario assume the true system is given by

LaTeX: y(t) = 0.2u(t-1) + 0.4u(t-2) + w(t)y(t)=0.2u(t1)+0.4u(t2)+w(t)y(t)=0.2u(t1)+0.4u(t2)+w(t)y(t)=0.2u(t1)+0.4u(t2)+w(t)

with LaTeX: w(t)\in N\left(0,1\right)w(t)N(0,1)w(t)w(t) white noise of variance 1. Assume an identification experiment is carried out with an input LaTeX: uuuu uncorrelated with LaTeX: wwww but with autocovariance

LaTeX: R_u(\tau) = \begin{cases}
1, &\tau=0\\
0.5, & |\tau|=1 \\
0, & |\tau|>1
\end{cases}Ru(τ)={1,τ=00.5,|τ|=10,|τ|>1Ru(τ)={1,τ=00.5,|τ|=10,|τ|>1Ru(τ)={1,τ=00.5,|τ|=10,|τ|>1

Calculate the asymptotic values of the estimates LaTeX: \hat{b}_1ˆb1ˆb1ˆb1 and LaTeX: \hat{b}_2ˆb2ˆb2ˆb2 when  LaTeX: N\to \infty.N.N.N. Are the estimates asymptotically correct? The model is of the correct form

LaTeX: y(t) = b_1 u(t-1) + b_2u(t-2) + e(t)y(t)=b1u(t1)+b2u(t2)+e(t)y(t)=b1u(t1)+b2u(t2)+e(t)y(t)=b1u(t1)+b2u(t2)+e(t).

Also determine the error variances LaTeX: \mathrm{Var}(b_1-\hat b_1)Var(b1ˆb1)Var(b1ˆb1)Var(b1ˆb1) and LaTeX: \mathrm{Var}(b_2-\hat b_2)Var(b2ˆb2)Var(b2ˆb2)Var(b2ˆb2)of the parameter estimates for finite amount of data LaTeX: NNNN.

c) Suggest another signal LaTeX: u(t)u(t)u(t)u(t), also with variance 1 as in b, which gives lower error variancesLaTeX: \mathrm{Var}(b_1-\hat b_1)Var(b1ˆb1)Var(b1ˆb1)Var(b1ˆb1) and LaTeX: \mathrm{Var}(b_2-\hat b_2)Var(b2ˆb2)Var(b2ˆb2)Var(b2ˆb2).


2 System Identification Practice

The data for this problem are in the file sysid02.mat. Download sysid02.mat. Load the data into Matlab, inside it you will find input and output signals u and y (the sample time is LaTeX: T_s=1Ts=1Ts=1Ts=1).

Use that data to construct one or more appropriate black-box models, choosing between ARX, OE, ARMAX and BJ structures of appropriate orders. For your best model report:

  • plot of the fitted model vs validation data. (Hint: compare())
  • parameter values and uncertainty
  • residual analysis plot (resid)
  • Bode plot (bode or bodeplot)
  • poles and zeros (pzmap)

You can either use the systemIdentification GUI or do it with matlab code that you write.


3. Modeling, Modelica and DAE systems

Subproblems

Consider the electric circuit below driven by a current source of input current LaTeX: IIII (and LaTeX: VVVV is a voltage).

electric.png

a) Write a DAE in the variables LaTeX: i_1i1i1i1, LaTeX: i_2i2i2i2, and LaTeX: VVVV, with LaTeX: IIII as input.

[In 2021-22 we have skipped talking about the differentiability index, and therefore questions of the form b) and c) will not be given in Jan 2022-3. Therefore skip the next two subproblems.

b) What is the differentiability index LaTeX: kkkk of the DAE ?

c) Let LaTeX: w = L_1i_1 - L_2 i_2w=L1i1L2i2w=L1i1L2i2w=L1i1L2i2and LaTeX: y=Vy=Vy=Vy=V. Show that the model can be written in the form

LaTeX: \begin{align*}
\dot w&= Aw + BI \\
y &= Cw + D_0I + \ldots +D_{k-1}I^{(k-1)}
\end{align*}˙w=Aw+BIy=Cw+D0I++Dk1I(k1)˙w=Aw+BIy=Cw+D0I++Dk1I(k1)˙w=Aw+BIy=Cw+D0I++Dk1I(k1)

where LaTeX: I^{(k-1)}I(k1)I(k1)I(k1) is the LaTeX: (k-1)(k1)(k1)(k1)-derivative of LaTeX: I,I,I,I, and LaTeX: kkkk is the differentiability index. ]

d) If the current source is replaced by a voltage source (similar diagram, but with voltage LaTeX: VVVV as input), is it possible to write the system in state space form LaTeX: \dot x = Ax + Bu, y=Cx+Du˙x=Ax+Bu,y=Cx+Du˙x=Ax+Bu,y=Cx+DuUnexpected text node: ' ?' (Note: different matrices LaTeX: A,B,C,DA,B,C,D than in c)

You can assume that parameters LaTeX: L_1L1L1L1 and LaTeX: L_2L2L2L2 are non-zero.


4. Supervised Learning - Practice and theory 

The EEG data needed here is not included, so you cant solve this problem. The problem would be more detailed on the exam. Don't spend all the time trying to optimize performance.

The google colab notebook xxx  loads data from an EEG experiment, measuring brain activity from persons looking on images on a computer screen. These images belong to 3 different categories, (denoted 0,1,2 in the data). It is known that the activities in the brain differ when processing images from these categories.

The EEG data has the following structure:

The data is split into a training set of X images which you should use to train your classifier and a test set of Y images which you should use to evaluate your algorithm.

a) Choose a good algorithm described in the course and train a classifier on the data. It is of course good if your algorithm gets a high performance, but your result will be judged mainly by your methodology, and how well you describe your method and result.

b) Describe how one could interpret the information one obtains from the singular value decomposition [U,S,V]=svd(A)

of the EEG data matrix A = (here follows a description of the matrix A). Say for instance that only 5 singular values are significantly larger then 0.


5. Causal Inference, Theory or Practice

The following DAG decscribes a linear Gaussian structural causal model, where we assume we do not know the parameters (the values on the edges).

causal.jpg

The equations of the SCM are given by

LaTeX: \begin{align*}
A& := N_A \\
B &:= N_B\\
X &:= A + 2B + N_C\\
D &:= 3B + 4X + N_D\\
Y &:= 2D+3X+N_E
\end{align*}A:=NAB:=NBX:=A+2B+NCD:=3B+4X+NDY:=2D+3X+NEA:=NAB:=NBX:=A+2B+NCD:=3B+4C+NDY:=2D+3C+NEA:=NAB:=NBX:=A+2B+NCD:=3B+4C+NDY:=2D+3C+NE

where  LaTeX: N_A,\ldots,N_ENA,,NENA,,NENA,,NE are normally distributed LaTeX: N(0,1)N(0,1)N(0,1)N(0,1) random variables.

a) We are interested in estimating the causal effect from LaTeX: XXXX to LaTeX: YYYUnexpected text node: ' ,' e.g. find LaTeX: \frac{\partial }{\partial x} E(Y | \mathrm{do}(X:=x))xE(Y|do(X:=x)) (which in this case is 11). Draw a figure indicating the updated DAG after an intervention has been made corresponding to this situation, aE(Y|do(X:=a))aE(Y|do(X:=a)).

b) If such an intervention is not practically possible, then describe how the causal effect from X to Y  can be obtained from linear regression using available data. Determine which of these linear regressions will give the correct value

LaTeX: \begin{align*}
&Y \sim X \\
&Y \sim X + B \\
&Y \sim X+A+B
\end{align*}YXYX+BYX+A+BYXYX+BYX+A+BYXYX+BYX+A+B

For the example LaTeX: Y\sim X+A+BYX+A+BYX+A+BYX+A+B this would  mean that we find the correct coefficient LaTeX: \theta_1=11θ1=11θ1=11θ1=11 (asymptotically when the number of data points goes to infinity) from the least squares regression

LaTeX: Y=\theta_1 X + \theta_2 A + \theta_3B + \textrm{noise}Y=θ1X+θ2A+θ3B+noiseY=θ1X+θ2A+θ3B+noiseY=θ1X+θ2A+θ3B+noise

c) Confirm your results numerically by generating a large amount of data points according to the true SCM and perform the three different linear regressions described in b. (Hint: In python you can use the ols command in the statsmodels package. You can also solve the problem in matlab).


6. Grey Box Identification

The following continuous time model describes the one dimensional position LaTeX: yyy of a mobile robot. The input signal LaTeX: uuu to a motor generates a force LaTeX: FFF on the robot.  The motor has a time constant LaTeX: TTT. The robot is initially at rest.

LaTeX: \begin{align*}
M \ddot y &= F \\
T\dot F &= -F + ku
\end{align*}
M¨y=FT˙F=F+kuM¨y=FT˙F=F+ku

Parameters LaTeX: M, TM,TM,T and LaTeX: kkk are unknown and should be estimated from output input data LaTeX: (y,u).(y,u).(y,u).

a) Use the state LaTeX: x = \begin{bmatrix} y \\ \dot y \\F \end{bmatrix}x=[y˙yF]x=[y˙yF] and write the model on state space form LaTeX: \dot x = A(\theta) x + B(\theta)u; \quad y = C(\theta) x; \quad x(0)=0˙x=A(θ)x+B(θ)u;y=C(θ)x;x(0)=0˙x=A(θ)x+B(θ)u;y=C(θ)x;x(0)=0

suitable for Grey-box identification.

b) Explain why all three parameters LaTeX: M,T,kM,T,kM,T,k can not be identified from any output input data LaTeX: (y,u)(y,u)(y,u)

b) The file problem6data.mat Download problem6data.mat contains data LaTeX: (y,u)(y,u)(y,u) sampled at LaTeX: T_s=0.1Ts=0.1Ts=0.1. (The data includes some noise.) Estimate the two parameters LaTeX: k,Tk,Tk,T assuming that the mass LaTeX: M=5M=5M=5 is known.


7. Bayesian Estimation

Say we know data LaTeX: y_1,\ldots,y_Ny1,,yN is drawn from a probability function

LaTeX: p(y;\theta) = (1-\theta)f_0(y) + \theta f_1(y)p(y;θ)=(1θ)f0(y)+θf1(y)

where LaTeX: f_0(y) \textrm{ and }  f_1(y)f0(y) and f1(y) are known functions, but where the parameter LaTeX: \theta \in (0,1)θ(0,1) is unknown and should be estimated.

a) Calculate the Fisher information LaTeX: I(\theta)I(θ) and show that any bias-free estimator LaTeX: \hat \theta = t(y)ˆθ=t(y) needs to satisfy

LaTeX: \begin{equation*}
E(\theta - \hat \theta)^2 \geq \frac{1}{N}\left[ \int \frac{(f_0(y)-f_1(y))^2}{(1-\theta)f_0(y)+\theta f_1(y)}dy \right]^{-1}
\end{equation*}E(θˆθ)21N[(f0(y)f1(y))2(1θ)f0(y)+θf1(y)dy]1

(where we assume the integral exists)

b) Suggest a method to estimate LaTeX: \thetaθ from data LaTeX: y_1,\ldots,y_Ny1,,yN which works well when LaTeX: N\to\inftyN (assuming LaTeX: f_0f0 is different from LaTeX: f_1f1).