indii/ml/filter/RauchTungStriebelSmoother.hpp

00001 #ifndef INDII_ML_FILTER_RAUCHTUNGSTRIEBELSMOOTHER_HPP
00002 #define INDII_ML_FILTER_RAUCHTUNGSTRIEBELSMOOTHER_HPP
00003 
00004 #include "Smoother.hpp"
00005 #include "RauchTungStriebelSmootherModel.hpp"
00006 
00007 #include <stack>
00008 
00009 namespace indii {
00010   namespace ml {
00011     namespace filter {
00012 
00013 /**
00014  * Rauch-Tung-Striebel (RTS) smoother.
00015  *
00016  * @author Lawrence Murray <lawrence@indii.org>
00017  * @version $Rev: 544 $
00018  * @date $Date: 2008-09-01 15:04:39 +0100 (Mon, 01 Sep 2008) $
00019  *
00020  * @param T The type of time.
00021  *
00022  * RauchTungStriebelSmoother is suitable for models with linear
00023  * transition and measurement functions, approximating state and noise
00024  * with indii::ml::aux::GaussianPdf distributions. The advantage of
00025  * the RauchTungStriebelSmoother compared to KalmanSmoother is that
00026  * the measurements are not required for the backwards pass.
00027  * 
00028  * @see indii::ml::filter for general usage guidelines.
00029  * @see LinearModel for more detail on linear filters.
00030  */
00031 template <class T>
00032 class RauchTungStriebelSmoother : public Smoother<T> {
00033 public:
00034   /**
00035    * Constructor.
00036    *
00037    * @param model Model to estimate.
00038    * @param tT \f$t_T\f$; starting time.
00039    * @param p_xT \f$p(\mathbf{x}_T)\f$; prior over the state at time
00040    * \f$t_T\f$.
00041    */
00042   RauchTungStriebelSmoother(RauchTungStriebelSmootherModel<T>* model,
00043       const T tT, const indii::ml::aux::GaussianPdf& p_xT);
00044 
00045   /**
00046    * Destructor.
00047    */
00048   virtual ~RauchTungStriebelSmoother();
00049 
00050   /**
00051    * Rewind system to time of previous measurement and
00052    * smooth.
00053    *
00054    * @param tn \f$t_n\f$; the time to which to rewind the
00055    * system. This must be less than the current time \f$t_{n+1}\f$.
00056    * @param p_xtn_ytn \f$p(\mathbf{x}_n\,|\,\mathbf{y}_{1:n})\f$; filter
00057    * density at time \f$t_n\f$.
00058    */
00059   virtual void smooth(const T tn,
00060       const indii::ml::aux::GaussianPdf& p_xtn_ytn);
00061 
00062   virtual indii::ml::aux::GaussianPdf smoothedMeasure();
00063 
00064 private:
00065   /**
00066    * Model to estimate.
00067    */
00068   RauchTungStriebelSmootherModel<T>* model;
00069 
00070 };
00071 
00072     }
00073   }
00074 }
00075 
00076 template <class T>
00077 indii::ml::filter::RauchTungStriebelSmoother<T>::RauchTungStriebelSmoother(
00078     RauchTungStriebelSmootherModel<T>* model, const T tT,
00079     const indii::ml::aux::GaussianPdf& p_xT) : Smoother<T>(tT, p_xT),
00080     model(model) {
00081   //
00082 }
00083 
00084 template <class T>
00085 indii::ml::filter::RauchTungStriebelSmoother<T>::~RauchTungStriebelSmoother() {
00086   //
00087 }
00088 
00089 template <class T>
00090 void indii::ml::filter::RauchTungStriebelSmoother<T>::smooth(const T tn,
00091     const indii::ml::aux::GaussianPdf& p_xtn_ytn) {
00092   namespace aux = indii::ml::aux;
00093 
00094   /* pre-condition */
00095   assert (tn < this->tn);
00096 
00097   /* rewind time */
00098   T delta = this->tn - tn;
00099   this->tn = tn;
00100 
00101   /* calculate smoothed state for this time */
00102   aux::GaussianPdf p_xtnp1_ytn(model->p_xtnp1_ytn(p_xtn_ytn, delta));
00103   this->p_xtn_ytT = model->p_xtn_ytT(this->p_xtn_ytT, p_xtnp1_ytn,
00104       p_xtn_ytn, delta);
00105 
00106   /* post-condition */
00107   assert (this->tn == tn);
00108 }
00109 
00110 template <class T>
00111 indii::ml::aux::GaussianPdf
00112     indii::ml::filter::RauchTungStriebelSmoother<T>::smoothedMeasure() {
00113   return model->p_y_x(this->p_xtn_ytT);
00114 }
00115 
00116 #endif
00117 

Generated on Wed Dec 17 15:11:57 2008 for dysii Dynamical Systems Library by  doxygen 1.5.3