indii/ml/filter/LinearModel.hpp

00001 #ifndef INDII_ML_FILTER_LINEARMODEL_HPP
00002 #define INDII_ML_FILTER_LINEARMODEL_HPP
00003 
00004 #include "../aux/matrix.hpp"
00005 #include "../aux/vector.hpp"
00006 
00007 #include "RauchTungStriebelSmootherModel.hpp"
00008 #include "KalmanSmootherModel.hpp"
00009 
00010 namespace indii {
00011   namespace ml {
00012     namespace filter {
00013 
00014 /**
00015  * Simple linear model.
00016  *
00017  * @author Lawrence Murray <lawrence@indii.org>
00018  * @version $Rev: 349 $
00019  * @date $Date: 2007-11-20 20:48:40 +0000 (Tue, 20 Nov 2007) $
00020  *
00021  * The system model takes the form:
00022  *
00023  * \f[\mathbf{x}_{t+1} = A\mathbf{x}_t + G\mathbf{w}_t\f]
00024  * 
00025  * where \f$\mathbf{w}_t\f$ is Gaussian noise with zero mean and
00026  * covariance matrix \f$Q\f$.
00027  *
00028  * The measurement model takes the form:
00029  *
00030  * \f[\mathbf{y}_t = C\mathbf{x}_t + \mathbf{v}_t\f]
00031  *
00032  * where \f$\mathbf{v}_t\f$ is Gaussian noise with zero mean and
00033  * covariance matrix \f$R\f$.
00034  *
00035  * For notational convenience, we define \f$\hat{\mathbf{x}}_{t|t}\f$ as
00036  * the expected value and \f$P_{t|t}\f$ as the covariance matrix of
00037  * the distribution \f$P\big(x_t\,|\,y_1,\ldots,y_t\big)\f$.
00038  */
00039 class LinearModel : public RauchTungStriebelSmootherModel<unsigned int>,
00040     public KalmanSmootherModel<unsigned int> {
00041 public:
00042   /**
00043    * Create new linear model.
00044    *
00045    * @param A \f$A\f$
00046    * @param G \f$G\f$
00047    * @param Q \f$Q\f$
00048    * @param C \f$C\f$
00049    * @param R \f$R\f$
00050    */
00051   LinearModel(indii::ml::aux::matrix& A, indii::ml::aux::matrix& G,
00052       indii::ml::aux::symmetric_matrix& Q, indii::ml::aux::matrix& C,
00053       indii::ml::aux::symmetric_matrix& R);
00054 
00055   /**
00056    * Destructor.
00057    */
00058   virtual ~LinearModel();
00059 
00060   /**
00061    * Predict next system state.
00062    *
00063    * \f{eqnarray*}
00064    * \hat{\mathbf{x}}_{t+1|t} & = & A\hat{\mathbf{x}}_{t|t} \\
00065    * P_{t+1|t} & = & AP_{t|t}A^T + GQG^T \\
00066    * \f}
00067    */
00068   virtual indii::ml::aux::GaussianPdf p_xtnp1_ytn(
00069       const indii::ml::aux::GaussianPdf& p_xtn_ytn, const unsigned int delta);
00070 
00071   /**
00072    * Refine prediction of next system state using next measurement.
00073    *
00074    * Let the Kalman gain be defined as:
00075    *
00076    * \f[K_{t+1} = P_{t+1|t}C^T(CP_{t+1|t}C^T + R)^{-1}\f]
00077    *
00078    * Then the measurement update proceeds as follows:
00079    *
00080    * \f{eqnarray*}
00081    * \hat{\mathbf{x}}_{t+1|t+1} & = & \hat{\mathbf{x}}_{t+1|t} +
00082    * K_{t+1}(\mathbf{y}_{t+1} - C\hat{\mathbf{x}}_{t+1|t}) \\
00083    * P_{t+1|t+1} & = & P_{t+1|t} - K_{t+1}CP_{t+1|t} \\
00084    * \f}
00085    */
00086   virtual indii::ml::aux::GaussianPdf p_xtnp1_ytnp1(
00087       const indii::ml::aux::GaussianPdf& p_xtnp1_ytn,
00088       const indii::ml::aux::vector& ytnp1, const unsigned int delta);
00089 
00090   /**
00091    * Predict measurement from system state.
00092    *
00093    * If p_x has mean \f$\hat{\mathbf{x}}\f$ and covariance \f$P_x\f$,
00094    * the return value has mean \f$\hat{\mathbf{y}}\f$ and covariance
00095    * \f$P_y\f$ defined by:
00096    *
00097    * \f{eqnarray*}
00098    * \hat{\mathbf{y}} & = & C\hat{\mathbf{x}} \\
00099    * P_y & = & C P_x C^T + R \\
00100    * \f}
00101    */
00102   virtual indii::ml::aux::GaussianPdf p_y_x(
00103       const indii::ml::aux::GaussianPdf& p_x);
00104 
00105   /**
00106    * Perform smoothing update.
00107    *
00108    * Let:
00109    *
00110    * \f[L_t = P_{t|t}A^TP_{t+1|t}^{-1}\f]
00111    *
00112    * The smoothing update proceeds as follows:
00113    *
00114    * \f{eqnarray*}
00115    * \hat{\mathbf{x}}_{t|T} & = & \hat{\mathbf{x}}_{t|t} +
00116    * L_t(\hat{\mathbf{x}}_{t+1|T} - \hat{\mathbf{x}}_{t+1|t}) \\
00117    * P_{t|T} & = & P_{t|t} + L_t(P_{t+1|T} - P_{t+1|t})L_t^T \\
00118    * \f}
00119    */
00120   virtual indii::ml::aux::GaussianPdf p_xtn_ytT(
00121       const indii::ml::aux::GaussianPdf& p_xtnp1_ytT,
00122       const indii::ml::aux::GaussianPdf& p_xtnp1_ytn,
00123       const indii::ml::aux::GaussianPdf& p_xtn_ytn,
00124       const unsigned int delta);
00125 
00126   virtual indii::ml::aux::GaussianPdf p_xtnm1_ytn(
00127       const indii::ml::aux::GaussianPdf& p_xtn_ytn, const unsigned int delta);
00128 
00129   virtual indii::ml::aux::GaussianPdf p_xtnm1_ytnm1(
00130       const indii::ml::aux::GaussianPdf& p_xtnm1_ytn,
00131       const indii::ml::aux::vector& ytnm1, const unsigned int delta);
00132 
00133 private:
00134   /**
00135    * Size of the state space.
00136    */
00137   const unsigned int N;
00138 
00139   /**
00140    * Size of the measurement space.
00141    */
00142   const unsigned int M;
00143 
00144   /**
00145    * \f$A\f$
00146    */
00147   indii::ml::aux::matrix A;
00148 
00149   /**
00150    * \f$A^T\f$
00151    */
00152   indii::ml::aux::matrix AT;
00153 
00154   /**
00155    * \f$G\f$
00156    */
00157   indii::ml::aux::matrix G;
00158 
00159   /**
00160    * \f$G^T\f$
00161    */
00162   indii::ml::aux::matrix GT;
00163 
00164   /**
00165    * \f$Q\f$
00166    */
00167   indii::ml::aux::symmetric_matrix Q;
00168 
00169   /**
00170    * \f$C\f$
00171    */
00172   indii::ml::aux::matrix C;
00173 
00174   /**
00175    * \f$C^T\f$
00176    */
00177   indii::ml::aux::matrix CT;
00178 
00179   /**
00180    * \f$R\f$
00181    */
00182   indii::ml::aux::symmetric_matrix R;
00183 
00184   /**
00185    * \f$A^{-1}\f$ for backwards pass.
00186    */
00187   indii::ml::aux::matrix AI;
00188 
00189 };
00190 
00191     }
00192   }
00193 }
00194 
00195 #endif
00196 

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