From Maximum A Posteriori we have the loss function:
But how do we set ?
Previously we were assuming that and can be thought of as positive-definite symmetric matrix weights that are often set to the process noise and measurement noise covariances of the system
So
But this assumes that we know the process noise and measurement noise beforehand.
We could use a datasheet, but that often isn't reliable
Supervised Covariance Estimation
Given we have a set of groundtruth state values, . We can compute the process noise and measurement noise as:
where from Maximum A Posteriori
\mathbf{e}{y,k}(\mathbf{x})=\mathbf{y}{k}-\mathbf{g}(\mathbf{x}_{k},\mathbf{0});; k=0\dots K
Once we have characterized the noise, we can proceed to using them in a real operational scenario. # Adaptive Covariance Estimation Using a trailing window of $L$ datapoints from the current time, $k$, we can adaptively change our covariances according to **Measurement Noise Covariance**\bar{\mathbf{e}}{y,k} = \frac{1}{L} \sum{\ell=k-1}^{k-L} \mathbf{e}_{y,\ell}
\mathbf{S}{y,k} = \frac{1}{L-1} \sum{\ell=k-1}^{k-L} (\mathbf{e}{y,\ell} - \bar{\mathbf{e}}{y,k})(\mathbf{e}{y,\ell} - \bar{\mathbf{e}}{y,k})
\mathbf{R}k = \mathbf{S}{y,k} - \frac{1}{L} \sum_{\ell=k-1}^{k-L} \mathbf{G}\ell \mathbf{P}\ell \mathbf{G}_\ell
\bar{\mathbf{e}}{v,k} = \frac{1}{L} \sum{\ell=k-1}^{k-L} \mathbf{e}_{v,\ell}
\mathbf{S}{v,k} = \frac{1}{L-1} \sum{\ell=k-1}^{k-L} (\mathbf{e}{v,\ell} - \bar{\mathbf{e}}{v,k})(\mathbf{e}{v,\ell} - \bar{\mathbf{e}}{v,k})
\mathbf{Q}k = \mathbf{S}{v,k} - \frac{1}{L} \sum_{\ell=k-1}^{k-L} \mathbf{F}{\ell-1} \mathbf{P}{\ell-1} \mathbf{F}_{\ell-1}
