Exam Preparation Notes Statistical Hypothesis Testing H 0 H_0 H 0 : Null hypothesis (default, uninteresting outcome).H < e m > 1 ∼ ¬ H < / e m > 0 H<em>1 \sim \neg H</em>0 H < e m > 1 ∼ ¬ H < / e m > 0 : Alternative hypothesis.Process:Assume H 0 H_0 H 0 . Under H 0 H_0 H 0 , compute statistic of interest (e.g., Q Q Q ). Compare statistic with its distribution under H 0 H_0 H 0 (e.g., X 2 ( df ) X^2(\text{df}) X 2 ( df ) ). p p p -value: Probability of observing Q Q Q or something more extreme if H 0 H_0 H 0 was true. P-Value and Significance Level Probability Density Function (PDF): p = f < e m > Q ( Q < / e m > data ) p = f<em>Q(Q</em>{\text{data}}) p = f < e m > Q ( Q < / e m > data ) Cumulative Distribution Function (CDF): F < e m > Q ( Q < / e m > data ) = ∫ < e m > − ∞ Q < / e m > data f Q ( Q ) d Q F<em>Q(Q</em>{\text{data}}) = \int<em>{-\infty}^{Q</em>{\text{data}}} f_Q(Q) dQ F < e m > Q ( Q < / e m > data ) = ∫ < e m > − ∞ Q < / e m > data f Q ( Q ) d Q p p p -value = 1 − F < e m > Q ( Q < / e m > data ) = 1 - F<em>Q(Q</em>{\text{data}}) = 1 − F < e m > Q ( Q < / e m > data ) Reject H 0 H_0 H 0 if p < \alpha (e.g., 0.05).α \alpha α : Probability of False Positives that we accept. State-Space Identification Motivation: Need "states" for control / fault detection / etc. System representation:Input: u ( t ) u(t) u ( t ) Output: y ( t ) y(t) y ( t ) State: x ( t ) x(t) x ( t ) Equation: y ( t ) = G ( q ) u ( t ) y(t) = G(q) u(t) y ( t ) = G ( q ) u ( t ) Controller design (e.g., LQR - Linear Quadratic Regulator) uses state feedback. Approaches to State-Space Modeling App 1) Learn I/O model → \rightarrow → transform it to state space. App 2) Learn state-space model directly. State-space models are identifiable up to a change of coordinates of the state. State-Space Model Equations State equation: x ( t + 1 ) = A x ( t ) + B u ( t ) x(t+1) = Ax(t) + Bu(t) x ( t + 1 ) = A x ( t ) + B u ( t ) Output equation: y ( t ) = C x ( t ) + D u ( t ) y(t) = Cx(t) + Du(t) y ( t ) = C x ( t ) + D u ( t ) Transfer function: G ( z ) = C ( z I − A ) − 1 B + D G(z) = C(zI - A)^{-1}B + D G ( z ) = C ( z I − A ) − 1 B + D Change of coordinates: x ~ ( t ) = P x ( t ) \tilde{x}(t) = Px(t) x ~ ( t ) = P x ( t ) Transformed state equation: x ~ ( t + 1 ) = P A P − 1 x ~ ( t ) + B u ( t ) \tilde{x}(t+1) = PAP^{-1}\tilde{x}(t) + Bu(t) x ~ ( t + 1 ) = P A P − 1 x ~ ( t ) + B u ( t ) Transformed output equation: y ( t ) = C P − 1 x ~ ( t ) + D u ( t ) y(t) = CP^{-1}\tilde{x}(t) + Du(t) y ( t ) = C P − 1 x ~ ( t ) + D u ( t ) Transfer function invariance: G ( z ) = C ( z I − A ) − 1 B + D = C ~ ( z I − A ~ ) − 1 B ~ + D ~ G(z) = C(zI - A)^{-1}B + D = \tilde{C}(zI - \tilde{A})^{-1}\tilde{B} + \tilde{D} G ( z ) = C ( z I − A ) − 1 B + D = C ~ ( z I − A ~ ) − 1 B ~ + D ~ Extended Observability Matrix Under similarity transformation:A ~ = P A P − 1 \tilde{A}=PAP^{-1} A ~ = P A P − 1 B ~ = P B \tilde{B}=PB B ~ = PB C ~ = C P − 1 \tilde{C}=CP^{-1} C ~ = C P − 1 D ~ = D \tilde{D}=D D ~ = D Extended Observability Matrix changes under coordinatesO = [ C C A C A 2 … C A r − 1 ] O = \begin{bmatrix} C \ CA \ CA^2 \ … \ CA^{r-1} \end{bmatrix} O = [ C C A C A 2 … C A r − 1 ] Realization Theory Goal: Given a learned I/O model, find a state-space representation. Learned I/O model: y ( t ) = G ( q ; θ ) u ( t ) y(t) = G(q; \theta)u(t) y ( t ) = G ( q ; θ ) u ( t ) G ( q ; θ ) = b < e m > 0 + b < / e m > 1 q − 1 + b < e m > 2 q − 2 + … + b < / e m > m q − m 1 + a < e m > 1 q − 1 + a < / e m > 2 q − 2 + … + a n q − n G(q; \theta) = \frac{b<em>0 + b</em>1q^{-1} + b<em>2q^{-2} + … + b</em>mq^{-m}}{1 + a<em>1q^{-1} + a</em>2q^{-2} + … + a_nq^{-n}} G ( q ; θ ) = 1 + a < e m > 1 q − 1 + a < / e m > 2 q − 2 + … + a n q − n b < e m > 0 + b < / e m > 1 q − 1 + b < e m > 2 q − 2 + … + b < / e m > m q − m Objective: Solve G ( q ) = C ( q I − A ) − 1 B + D G(q) = C(qI - A)^{-1}B + D G ( q ) = C ( q I − A ) − 1 B + D G ( q ; θ ) = b < e m > 0 + b < / e m > 1 q − 1 + b < e m > 2 q − 2 + b < / e m > 3 q − 3 1 + a < e m > 1 q − 1 + a < / e m > 2 q − 2 + a 3 q − 3 G(q; \theta) = \frac{b<em>0 + b</em>1q^{-1} + b<em>2q^{-2} + b</em>3q^{-3}}{1 + a<em>1q^{-1} + a</em>2q^{-2} + a_3q^{-3}} G ( q ; θ ) = 1 + a < e m > 1 q − 1 + a < / e m > 2 q − 2 + a 3 q − 3 b < e m > 0 + b < / e m > 1 q − 1 + b < e m > 2 q − 2 + b < / e m > 3 q − 3 State equation:x ( t + 1 ) = [ − a < e m > 1 − a < / e m > 2 a m p ; − a 3 1 a m p ; 0 a m p ; 0 0 a m p ; 1 a m p ; 0 ] x ( t ) + [ 1 0 0 ] u ( t ) x(t+1) = \begin{bmatrix} -a<em>1 & -a</em>2 & -a_3 \ 1 & 0 & 0 \ 0 & 1 & 0 \end{bmatrix} x(t) + \begin{bmatrix} 1 \ 0 \ 0 \end{bmatrix} u(t) x ( t + 1 ) = [ − a < e m > 1 − a < / e m > 2 am p ; − a 3 1 am p ; 0 am p ; 0 0 am p ; 1 am p ; 0 ] x ( t ) + [ 1 0 0 ] u ( t ) Output equation:y ( t ) = [ b < e m > 1 b < / e m > 2 a m p ; b < e m > 3 ] x ( t ) + [ b < / e m > 0 ] u ( t ) y(t) = \begin{bmatrix} b<em>1 & b</em>2 & b<em>3 \end{bmatrix} x(t) + [b</em>0]u(t) y ( t ) = [ b < e m > 1 b < / e m > 2 am p ; b < e m > 3 ] x ( t ) + [ b < / e m > 0 ] u ( t ) State Estimation: Kalman Filter Optimal state estimator is the Kalman Filter. State-space model:State equation: x ( t + 1 ) = A x ( t ) + B u ( t ) + w ( t ) x(t+1) = Ax(t) + Bu(t) + w(t) x ( t + 1 ) = A x ( t ) + B u ( t ) + w ( t ) Output equation: y ( t ) = C x ( t ) + D u ( t ) + v ( t ) y(t) = Cx(t) + Du(t) + v(t) y ( t ) = C x ( t ) + D u ( t ) + v ( t ) w ( t ) w(t) w ( t ) : Process noise.v ( t ) v(t) v ( t ) : Measurement noise. Rearrange output equation: C x ( t ) = y ( t ) − D u ( t ) − v ( t ) Cx(t) = y(t) - Du(t) - v(t) C x ( t ) = y ( t ) − D u ( t ) − v ( t ) State Estimation Equations y ( t ) = C x ( t ) + D u ( t ) + v ( t ) y(t) = Cx(t) + Du(t) + v(t) y ( t ) = C x ( t ) + D u ( t ) + v ( t ) y ( t + 1 ) = C [ A x ( t ) + B u ( t ) + w ( t ) ] + D u ( t + 1 ) + v ( t + 1 ) = C A x ( t ) + C B u ( t ) + D u ( t + 1 ) + C w ( t ) + v ( t + 1 ) y(t+1) = C[Ax(t) + Bu(t) + w(t)] + Du(t+1) + v(t+1) = CAx(t) + CBu(t) + Du(t+1) + Cw(t) + v(t+1) y ( t + 1 ) = C [ A x ( t ) + B u ( t ) + w ( t )] + D u ( t + 1 ) + v ( t + 1 ) = C A x ( t ) + CB u ( t ) + D u ( t + 1 ) + Cw ( t ) + v ( t + 1 ) Vector of outputs:[ y ( t ) y ( t + 1 ) y ( t + 2 ) … y ( t + r − 1 ) ] = [ C C A C A 2 … C A r − 1 ] x ( t ) + [ D a m p ; 0 a m p ; 0 a m p ; … C B a m p ; D a m p ; 0 a m p ; … C A B a m p ; C B a m p ; D a m p ; … … a m p ; … a m p ; … a m p ; … C A r − 2 B a m p ; C A r − 3 B a m p ; C A r − 4 B a m p ; … ] [ u ( t ) u ( t + 1 ) u ( t + 2 ) … ] + [ v ( t ) w ( t ) w ( t + 1 ) … ] \begin{bmatrix} y(t) \ y(t+1) \ y(t+2) \ … \ y(t+r-1) \end{bmatrix} = \begin{bmatrix} C \ CA \ CA^2 \ … \ CA^{r-1} \end{bmatrix} x(t) + \begin{bmatrix} D & 0 & 0 & … \ CB & D & 0 & … \ CAB & CB & D & … \ … & … & … & … \ CA^{r-2}B & CA^{r-3}B & CA^{r-4}B & … \end{bmatrix} \begin{bmatrix} u(t) \ u(t+1) \ u(t+2) \ … \end{bmatrix} + \begin{bmatrix} v(t) \ w(t) \ w(t+1) \ … \end{bmatrix} [ y ( t ) y ( t + 1 ) y ( t + 2 ) … y ( t + r − 1 ) ] = [ C C A C A 2 … C A r − 1 ] x ( t ) + [ D am p ; 0 am p ; 0 am p ; … CB am p ; D am p ; 0 am p ; … C A B am p ; CB am p ; D am p ; … … am p ; … am p ; … am p ; … C A r − 2 B am p ; C A r − 3 B am p ; C A r − 4 B am p ; … ] [ u ( t ) u ( t + 1 ) u ( t + 2 ) … ] + [ v ( t ) w ( t ) w ( t + 1 ) … ] Re-arranging equations Define:O < e m > r = [ C C A C A 2 … C A r − 1 ] O<em>r = \begin{bmatrix} C \ CA \ CA^2 \ … \ CA^{r-1} \end{bmatrix} O < e m > r = [ C C A C A 2 … C A r − 1 ] S < / e m > r = [ D a m p ; 0 a m p ; 0 a m p ; … C B a m p ; D a m p ; 0 a m p ; … C A B a m p ; C B a m p ; D a m p ; … … a m p ; … a m p ; … a m p ; … C A r − 2 B a m p ; C A r − 3 B a m p ; C A r − 4 B a m p ; … ] S</em>r = \begin{bmatrix} D & 0 & 0 & … \ CB & D & 0 & … \ CAB & CB & D & … \ … & … & … & … \ CA^{r-2}B & CA^{r-3}B & CA^{r-4}B & … \end{bmatrix} S < / e m > r = [ D am p ; 0 am p ; 0 am p ; … CB am p ; D am p ; 0 am p ; … C A B am p ; CB am p ; D am p ; … … am p ; … am p ; … am p ; … C A r − 2 B am p ; C A r − 3 B am p ; C A r − 4 B am p ; … ] Rewrite: O < e m > r x ( t ) = y < / e m > r ( t ) − S < e m > r u < / e m > r ( t ) − v r ( t ) O<em>r x(t) = y</em>r(t) - S<em>r u</em>r(t) - v_r(t) O < e m > r x ( t ) = y < / e m > r ( t ) − S < e m > r u < / e m > r ( t ) − v r ( t ) In theory: x ( t ) = O < e m > r − 1 ( y < / e m > r ( t ) − S < e m > r u < / e m > r ( t ) ) x(t) = O<em>r^{-1} (y</em>r(t) - S<em>r u</em>r(t) ) x ( t ) = O < e m > r − 1 ( y < / e m > r ( t ) − S < e m > r u < / e m > r ( t )) But use Kalman Filter (KF) instead. Solving Linear Equations A x = b Ax = b A x = b : 3 possibilitiesUnique solution: A − 1 b A^{-1}b A − 1 b , A is full column rank. 0 solutions: x x x solves m i n ∣ ∣ A x − b ∣ ∣ 2 min ||Ax - b||^2 min ∣∣ A x − b ∣ ∣ 2 ∞ \infty ∞ solutions: x x x solves m i n ∣ ∣ x ∣ ∣ 2 min ||x||^2 min ∣∣ x ∣ ∣ 2 s.t. A x = b Ax = b A x = b Kalman Filter Algorithm State equation: x ( t + 1 ) = A x ( t ) + B u ( t ) + w ( t ) x(t+1) = Ax(t) + Bu(t) + w(t) x ( t + 1 ) = A x ( t ) + B u ( t ) + w ( t ) Output equation: y ( t ) = C x ( t ) + D u ( t ) + v ( t ) y(t) = Cx(t) + Du(t) + v(t) y ( t ) = C x ( t ) + D u ( t ) + v ( t ) Initialization: x ^ 0 ∣ 0 \hat{x}_{0|0} x ^ 0∣0 Prediction:x ^ < e m > 1 ∣ 0 = A x ^ < / e m > 0 ∣ 0 + B u ( 0 ) \hat{x}<em>{1|0} = A \hat{x}</em>{0|0} + Bu(0) x ^ < e m > 1∣0 = A x ^ < / e m > 0∣0 + B u ( 0 ) Update:x ^ < e m > 1 ∣ 1 = x ^ < / e m > 1 ∣ 0 + K ( y ( 1 ) − C x ^ 1 ∣ 0 − D u ( 0 ) ) \hat{x}<em>{1|1} = \hat{x}</em>{1|0} + K (y(1) - C \hat{x}_{1|0} - Du(0)) x ^ < e m > 1∣1 = x ^ < / e m > 1∣0 + K ( y ( 1 ) − C x ^ 1∣0 − D u ( 0 )) K K K : Kalman Gain. Output prediction error: y ( 1 ) − C x ^ 1 ∣ 0 − D u ( 0 ) y(1) - C \hat{x}_{1|0} - Du(0) y ( 1 ) − C x ^ 1∣0 − D u ( 0 ) Next step prediction: x ^ < e m > 2 ∣ 1 = A x ^ < / e m > 1 ∣ 1 + B u ( 1 ) \hat{x}<em>{2|1} = A \hat{x}</em>{1|1} + Bu(1) x ^ < e m > 2∣1 = A x ^ < / e m > 1∣1 + B u ( 1 ) Continue with update step Knowt Play Call Kai