indii/ml/aux/StochasticProcess.hpp

00001 #ifndef INDII_ML_AUX_STOCHASTICPROCESS_HPP
00002 #define INDII_ML_AUX_STOCHASTICPROCESS_HPP
00003 
00004 #include "vector.hpp"
00005 #include "matrix.hpp"
00006 
00007 #include "boost/serialization/serialization.hpp"
00008 
00009 namespace indii {
00010   namespace ml {
00011     namespace aux {
00012 
00013 /**
00014  * Abstract stochastic process.
00015  *
00016  * @author Lawrence Murray <lawrence@indii.org>
00017  * @version $Rev: 540 $
00018  * @date $Date: 2008-08-31 14:41:46 +0100 (Sun, 31 Aug 2008) $
00019  */
00020 template <class T = unsigned int>
00021 class StochasticProcess {
00022 public:
00023   /**
00024    * Default constructor.
00025    *
00026    * Initialises the process with zero dimensions. This should
00027    * generally only be used when the object is to be restored from a
00028    * serialization.
00029    */
00030   StochasticProcess();
00031 
00032   /**
00033    * Constructor.
00034    *
00035    * @param N \f$N\f$; number of dimensions of the process.
00036    */
00037   StochasticProcess(const unsigned int N);
00038 
00039   /**
00040    * Destructor.
00041    */
00042   virtual ~StochasticProcess();
00043 
00044   /**
00045    * Get the dimensionality of the process.
00046    */
00047   unsigned int getDimensions() const;
00048 
00049   /**
00050    * Set the dimensionality of the process.
00051    *
00052    * @param N Dimensionality of the process.
00053    * @param preserve True to preserve the current sufficient
00054    * statistics of the process in the lower dimensional space,
00055    * false if these may be discarded.
00056    */
00057   virtual void setDimensions(const unsigned int N,
00058       const bool preserve = false) = 0;
00059 
00060   /**
00061    * Get the drift of the process.
00062    *
00063    * @return The drift of the process.
00064    */
00065   virtual const vector& getDrift() = 0;
00066 
00067   /**
00068    * Get the diffusion of the process.
00069    *
00070    * @return The diffusion of the process.
00071    */
00072   virtual const symmetric_matrix& getDiffusion() = 0;
00073 
00074   /**
00075    * Get the expected value of the process after a given time.
00076    *
00077    * @param delta \f$\Delta t\f$; time step.
00078    *
00079    * @return \f$\mathbf{\mu}(\Delta t)\f$; expected value of the process
00080    * after time \f$\Delta t\f$.
00081    */
00082   virtual vector getExpectation(const T delta) = 0;
00083 
00084   /**
00085    * Get the covariance of the process after a given time.
00086    *
00087    * @param delta \f$\Delta t\f$; time step.
00088    *
00089    * @return \f$\Sigma(\Delta t)\f$; covariance of the process after
00090    * time \f$\Delta t\f$.
00091    */
00092   virtual symmetric_matrix getCovariance(const T delta) = 0;
00093 
00094   /**
00095    * Sample from the process.
00096    *
00097    * @param delta \f$\Delta t\f$; time step.
00098    *
00099    * @return A sample from the process after time \f$\Delta t\f$.
00100    */
00101   virtual vector sample(const T delta) = 0;
00102 
00103   /**
00104    * Calculate the density of the distribution at a given point after
00105    * a given time has elapsed.
00106    *
00107    * @param delta \f$\Delta t\f$; elapsed time.
00108    * @param x \f$\mathbf{x}\f$; the point at which to calculate the
00109    * density.
00110    *
00111    * @return The density of the distribution at \f$\mathbf{x}\f$ after
00112    * time \f$\Delta t\f$.
00113    */
00114   virtual double densityAt(const T delta, const vector& x) = 0;
00115 
00116 protected:
00117   /**
00118    * \f$N\f$; number of dimensions.
00119    */
00120   unsigned int N;
00121 
00122 private:
00123   /**
00124    * Serialize, or restore from serialization.
00125    */
00126   template<class Archive>
00127   void serialize(Archive& ar, const unsigned int version);
00128 
00129   /*
00130    * Boost.Serialization requirements.
00131    */
00132   friend class boost::serialization::access;
00133 
00134 };
00135 
00136     }
00137   }
00138 }
00139 
00140 template <class T>
00141 indii::ml::aux::StochasticProcess<T>::StochasticProcess() : N(0) {
00142   //
00143 }
00144 
00145 template <class T>
00146 indii::ml::aux::StochasticProcess<T>::StochasticProcess(
00147     const unsigned int N) : N(N) {
00148   //
00149 }
00150 
00151 template <class T>
00152 indii::ml::aux::StochasticProcess<T>::~StochasticProcess() {
00153   //
00154 }
00155 
00156 template <class T>
00157 inline unsigned int indii::ml::aux::StochasticProcess<T>::getDimensions()
00158     const {
00159   return N;
00160 } 
00161 
00162 template <class T>
00163 template <class Archive>
00164 void indii::ml::aux::StochasticProcess<T>::serialize(Archive& ar,
00165     const unsigned int version) {
00166   ar & N;
00167 }
00168 
00169 #endif
00170 

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