7 #ifndef SSMPACK_FILTER_KALMAN_HPP
8 #define SSMPACK_FILTER_KALMAN_HPP
29 template <
class STA_MAP,
class OBS_MAP>
36 Hierarchical<Markov<Gaussian, STA_MAP, Gaussian>,
37 Memoryless<Gaussian, OBS_MAP>>;
40 std::tuple<arma::vec, arma::mat>;
46 const arma::mat &dyn_mat_;
48 const arma::mat &mes_mat_;
50 const arma::mat &dyn_cov_;
52 const arma::mat &mes_cov_;
58 arma::vec p_state_vec_;
60 arma::mat p_state_cov_;
70 process_.template getProcess<0>().getCPDF().getParamMap().transfer),
72 process_.template getProcess<1>().getCPDF().getParamMap().transfer),
73 dyn_cov_(process_.template getProcess<0>()
77 mes_cov_(process_.template getProcess<1>()
93 template <
class... TArgs>
98 std::get<0>(process_.template getProcess<0>().getCPDF().getParamMap()(
99 state_vec_, args...));
100 p_state_cov_ = dyn_mat_ * state_cov_ * dyn_mat_.t() + dyn_cov_;
117 template <
class... TArgs>
119 const TArgs &... args) {
120 arma::vec inovation =
122 std::get<0>(process_.template getProcess<1>().getCPDF().getParamMap()(
123 p_state_vec_, args...));
125 arma::mat inovation_cov = mes_mat_ * p_state_cov_ * mes_mat_.t() + mes_cov_;
126 arma::mat kalman_gain =
127 p_state_cov_ * mes_mat_.t() * arma::inv_sympd(inovation_cov);
129 state_vec_ = p_state_vec_ + kalman_gain * inovation;
130 state_cov_ = p_state_cov_ - kalman_gain * mes_mat_ * p_state_cov_;
131 return std::make_tuple(state_vec_, state_cov_);
138 state_vec_ = process_.template getProcess<0>().getInitialPDF().getMean();
140 process_.template getProcess<0>().getInitialPDF().getCovariance();
141 return std::make_tuple(state_vec_, state_cov_);
145 template <
class STA_MAP,
class OBS_MAP>
147 Hierarchical<Markov<Gaussian, STA_MAP, Gaussian>,
148 Memoryless<Gaussian, OBS_MAP>> process) {
155 #endif // SSMPACK_FILTER_KALMAN_HPP
A stochastic process constructed as hierarchy of stochastic processes.
Kalman(const TProcess &process)
Construct a Kalman filter.
Conditional distribution function.
Kalman< STA_MAP, OBS_MAP > makeKalman(Hierarchical< Markov< Gaussian, STA_MAP, Gaussian >, Memoryless< Gaussian, OBS_MAP >> process)
A first-order Markov process.
void predict(const TArgs &...args)
Prediction.
TCompeleteState initialize()
Initialization.
Hierarchical< Markov< Gaussian, STA_MAP, Gaussian >, Memoryless< Gaussian, OBS_MAP >> TProcess
Type of process object.
A Memoryless (independent/white) random process.
A D-dimensional multivariate Gaussian distribution.
TCompeleteState correct(const arma::vec &measurement, const TArgs &...args)
Correction.
std::tuple< arma::vec, arma::mat > TCompeleteState
Type of the posterior state .