indii/ml/filter/TwoFilterSmoother.hpp

00001 #ifndef INDII_ML_FILTER_TWOFILTERSMOOTHER_HPP
00002 #define INDII_ML_FILTER_TWOFILTERSMOOTHER_HPP
00003 
00004 #include "../aux/vector.hpp"
00005 #include "../aux/Pdf.hpp"
00006 
00007 #include "Smoother.hpp"
00008 
00009 namespace indii {
00010   namespace ml {
00011     namespace filter {
00012 /**
00013  * Abstract smoother for estimating the state of a system by fusing
00014  * forward and backward filtering passes.
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  * @param P The type of probability distribution used to represent the
00022  * system state.
00023  * 
00024  * @see indii::ml::filter for general usage guidelines.
00025  */
00026 template <class T = unsigned int, class P = indii::ml::aux::GaussianPdf>
00027 class TwoFilterSmoother : public Smoother<T,P> {
00028 public:
00029   /**
00030    * Constructor.
00031    *
00032    * @param tT \f$t_T\f$; starting time.
00033    * @param p_xT \f$p(\mathbf{x}_T)\f$; prior over the state at time
00034    * \f$t_T\f$.
00035    */
00036   TwoFilterSmoother(const T tT, const P& p_xT);
00037 
00038   /**
00039    * Destructor.
00040    */
00041   virtual ~TwoFilterSmoother();
00042 
00043   /**
00044    * Get distribution over the state at the current time given present
00045    * and future measurements.
00046    *
00047    * @return \f$P\big(\mathbf{x}(t_n)\, |
00048    * \,\mathbf{y}(t_n),\ldots,\mathbf{y}(t_T)\big)\f$; distribution
00049    * over the current state given present and future measurements.
00050    */
00051   P& getBackwardFilteredState();
00052 
00053   /**
00054    * Set distribution over the state at the current time given present
00055    * and future measurements.
00056    *
00057    * @param p_xtn_ytn \f$P\big(\mathbf{x}(t_n)\, |
00058    * \,\mathbf{y}(t_n),\ldots,\mathbf{y}(t_T)\big)\f$; distribution
00059    * over the current state given present and future measurements.
00060    */
00061   void setBackwardFilteredState(const P& p_xtn_ytn);
00062 
00063   /**
00064    * Rewind system to time of previous measurement and
00065    * smooth. Performs the backward filtering step and fuses this with
00066    * the given prediction from the forward filtering step to produce
00067    * the smoothed prediction.
00068    *
00069    * @param tn \f$t_n\f$; the time to which to rewind the
00070    * system. This must be less than the current time \f$t_{n+1}\f$.
00071    * @param ytn \f$\mathbf{y}_n\f$; measurement at time \f$t_n\f$.
00072    * @param p_xtn_ytn \f$p(\mathbf{x}_n\,|\,\mathbf{y}_{1:n})\f$;
00073    * forward filter density.
00074    */
00075   virtual void smooth(const T tn, const aux::vector& ytn,
00076       const P& p_xtn_ytn) = 0;
00077 
00078   /**
00079    * Apply the measurement function to the current filtered state to
00080    * obtain an estimated measurement.
00081    *
00082    * @return The estimated measurement.
00083    */
00084   virtual aux::GaussianPdf backwardMeasure() = 0;
00085 
00086 protected:
00087   /**
00088    * \f$p(\mathbf{x}_n\,|\,\mathbf{y}_{n:T})\f$; backward filter density.
00089    */
00090   P p_xtn_ytn_b;
00091 
00092 };
00093 
00094     }
00095   }
00096 }
00097 
00098 template <class T, class P>
00099 indii::ml::filter::TwoFilterSmoother<T,P>::TwoFilterSmoother(const T tT,
00100     const P& p_xT) : Smoother<T,P>(tT, p_xT), p_xtn_ytn_b(p_xT) {
00101   //
00102 }
00103 
00104 template <class T, class P>
00105 indii::ml::filter::TwoFilterSmoother<T,P>::~TwoFilterSmoother() {
00106   //
00107 }
00108 
00109 template <class T, class P>
00110 inline P& indii::ml::filter::TwoFilterSmoother<T,P>::getBackwardFilteredState() {
00111   return this->p_xtn_ytn_b;
00112 }
00113 
00114 template <class T, class P>
00115 void indii::ml::filter::TwoFilterSmoother<T,P>::setBackwardFilteredState(
00116     const P& p_xtn_ytn) {
00117   this->p_xtn_ytn_b = p_xtn_ytn;
00118 }
00119 
00120 #endif
00121 

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