\\\\(
\nonumber
\newcommand{\bevisslut}{$\blacksquare$}
\newenvironment{matr}[1]{\hspace{-.8mm}\begin{bmatrix}\hspace{-1mm}\begin{array}{#1}}{\end{array}\hspace{-1mm}\end{bmatrix}\hspace{-.8mm}}
\newcommand{\transp}{\hspace{-.6mm}^{\top}}
\newcommand{\maengde}[2]{\left\lbrace \hspace{-1mm} \begin{array}{c|c} #1 & #2 \end{array} \hspace{-1mm} \right\rbrace}
\newenvironment{eqnalign}[1]{\begin{equation}\begin{array}{#1}}{\end{array}\end{equation}}
\newcommand{\eqnl}{}
\newcommand{\matind}[3]{{_\mathrm{#1}\mathbf{#2}_\mathrm{#3}}}
\newcommand{\vekind}[2]{{_\mathrm{#1}\mathbf{#2}}}
\newcommand{\jac}[2]{{\mathrm{Jacobi}_\mathbf{#1} (#2)}}
\newcommand{\diver}[2]{{\mathrm{div}\mathbf{#1} (#2)}}
\newcommand{\rot}[1]{{\mathbf{rot}\mathbf{(#1)}}}
\newcommand{\am}{\mathrm{am}}
\newcommand{\gm}{\mathrm{gm}}
\newcommand{\E}{\mathrm{E}}
\newcommand{\Span}{\mathrm{span}}
\newcommand{\mU}{\mathbf{U}}
\newcommand{\mA}{\mathbf{A}}
\newcommand{\mB}{\mathbf{B}}
\newcommand{\mC}{\mathbf{C}}
\newcommand{\mD}{\mathbf{D}}
\newcommand{\mE}{\mathbf{E}}
\newcommand{\mF}{\mathbf{F}}
\newcommand{\mK}{\mathbf{K}}
\newcommand{\mI}{\mathbf{I}}
\newcommand{\mM}{\mathbf{M}}
\newcommand{\mN}{\mathbf{N}}
\newcommand{\mQ}{\mathbf{Q}}
\newcommand{\mT}{\mathbf{T}}
\newcommand{\mV}{\mathbf{V}}
\newcommand{\mW}{\mathbf{W}}
\newcommand{\mX}{\mathbf{X}}
\newcommand{\ma}{\mathbf{a}}
\newcommand{\mb}{\mathbf{b}}
\newcommand{\mc}{\mathbf{c}}
\newcommand{\md}{\mathbf{d}}
\newcommand{\me}{\mathbf{e}}
\newcommand{\mn}{\mathbf{n}}
\newcommand{\mr}{\mathbf{r}}
\newcommand{\mv}{\mathbf{v}}
\newcommand{\mw}{\mathbf{w}}
\newcommand{\mx}{\mathbf{x}}
\newcommand{\mxb}{\mathbf{x_{bet}}}
\newcommand{\my}{\mathbf{y}}
\newcommand{\mz}{\mathbf{z}}
\newcommand{\reel}{\mathbb{R}}
\newcommand{\mL}{\bm{\Lambda}}
\newcommand{\mnul}{\mathbf{0}}
\newcommand{\trap}[1]{\mathrm{trap}(#1)}
\newcommand{\Det}{\operatorname{Det}}
\newcommand{\adj}{\operatorname{adj}}
\newcommand{\Ar}{\operatorname{Areal}}
\newcommand{\Vol}{\operatorname{Vol}}
\newcommand{\Rum}{\operatorname{Rum}}
\newcommand{\diag}{\operatorname{\bf{diag}}}
\newcommand{\bidiag}{\operatorname{\bf{bidiag}}}
\newcommand{\spanVec}[1]{\mathrm{span}{#1}}
\newcommand{\Div}{\operatorname{Div}}
\newcommand{\Rot}{\operatorname{\mathbf{Rot}}}
\newcommand{\Jac}{\operatorname{Jacobi}}
\newcommand{\Tan}{\operatorname{Tan}}
\newcommand{\Ort}{\operatorname{Ort}}
\newcommand{\Flux}{\operatorname{Flux}}
\newcommand{\Cmass}{\operatorname{Cm}}
\newcommand{\Imom}{\operatorname{Im}}
\newcommand{\Pmom}{\operatorname{Pm}}
\newcommand{\IS}{\operatorname{I}}
\newcommand{\IIS}{\operatorname{II}}
\newcommand{\IIIS}{\operatorname{III}}
\newcommand{\Le}{\operatorname{L}}
\newcommand{\app}{\operatorname{app}}
\newcommand{\M}{\operatorname{M}}
\newcommand{\re}{\mathrm{Re}}
\newcommand{\im}{\mathrm{Im}}
\newcommand{\compl}{\mathbb{C}}
\newcommand{\e}{\mathrm{e}}
\\\\)
Use the Kalman filter to make one step predictions of the height and speed of an object that is observed in a throw. The data was taken from a video of a throw. See the exercise_kalmanfilter.R script to get started. You find a solution suggestion here exercise_kalmanfilter_solution.R
Data: Height of object. Use the the height (height in meters) as your observed model output and Time as the time of the observations. The data was extracted from a video of a throw. The data is here exercise_kalmanfilter_data.csv
In the script are several tasks
Write the missing parts of the Kalman filter
Here you should fill the missing prediction and updating equations. After filling them, plot the one-step predicted and reconstructed output.
Check with the FKF package Kalman filter that you get the same result.
Try some different values
Try changing the parameters of the model
Note that the Kalman filter estimate the state $X$ and the state covariance matrix $\Sigma^{XX}$.
However the system noise variance
$$
\Sigma_1 = \begin{bmatrix} 0.05^2 & 0\\\\ 0 & 0.05^2\end{bmatrix}
$$
and the output noise variance
$$
\Sigma_2 = 0.1^2
$$
are simply specified in the model.
The parameters of the model are also constant, in this case the matrices $A$,$B$ and $C$ which consists of 0 and 1 (they could just have any value). The input $U$ would in most cases be time series, however in this case we just set it constant to
$$
g = 9.82 ~\mathrm{m/s^2} = 9.82/30 ~\mathrm{m/frame^2}
$$
note the video was 30 frames per second.
Try specifying different values of $g$ and see how that affect the result.
Initial condition of the state-vector
The state vector initial condition
$$
X_0 = [\text{height} , \text{velocity}]^T = [2.1 \text{ m}, 11/30 \text{ m/frame}]^T
$$
and its covariance
$$
\Sigma^{XX}_0 = \begin{bmatrix} 0.5^2 & 0 \\\\ 0 & 1^2 \end{bmatrix}
$$
are set, but change as they are updated in each time step.
Try changing their initial values, try a wrong starting value of $X$ and try both very low and very high values of the $\Sigma^{XX}_0$ and see how it affects the tracking of the state.
Add noise
Try adding noise to $y$ and see what happens, find some new appropriate values for the initial state and output variances.
Add a step
Try adding noise to $y$ and see what happens, find some new appropriate values for the initial state and output variances.
Estimate the g
Extend the model to also have the acceleration in the state vector. You need to specify the transition matrix $A$, such that the acceleration is added to the speed.
Again, play around with initial values to get a good fit. What if you for example.