work/mixpp/bdm/stat/libBM.h

Go to the documentation of this file.
00001 
00013 #ifndef BM_H
00014 #define BM_H
00015 
00016 #include <itpp/itbase.h>
00017 //#include <std>
00018 
00019 using namespace itpp;
00020 
00027 class RV {
00028 protected:
00030         int size;
00032         int len;
00033         ivec ids;
00034         ivec sizes;
00035         ivec times;
00036         ivec obs;
00037         Array<std::string> names;
00038 
00039 private:
00040         void init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs );
00041 public:
00043         RV ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs );
00045         RV ( ivec ids );
00047         RV ();
00048 
00050         friend std::ostream &operator<< ( std::ostream &os, const RV &rv );
00051 
00053         int count() const {return size;} ;
00054 
00055         //TODO why not inline and later??
00056 
00058         ivec find ( RV rv2 );
00060         RV add (const RV &rv2 );
00062         RV subt ( RV rv2 );
00064         RV subselect ( ivec ind );
00066         RV operator() ( ivec ind );
00068         void t ( int delta );
00070         ivec indexlist();
00071 };
00072 
00074 
00075 class fnc {
00076 protected:
00077         int dimy;
00078 public:
00080         virtual vec eval ( const vec &cond ) {
00081                 return vec ( 0 );
00082         }; //Fixme: virtual?
00083 
00085         int _dimy() const{return dimy;}
00086 
00088         virtual ~fnc() {};
00089 };
00090 
00091 
00093 
00094 class epdf {
00095 protected:
00096         RV rv;
00097 public:
00099         epdf() :rv ( ivec ( 0 ) ) {};
00100 
00102         epdf ( const RV &rv0 ) :rv ( rv0 ) {};
00103 
00105 //      virtual vec moment ( const int order = 1 );
00107         virtual vec sample () =0;
00109         virtual double eval ( const vec &val ) {return 0.0;};
00110 
00112         virtual double evalpdflog ( const vec &val ) {return 0.0;};
00113 
00115         virtual vec mean()=0;
00116         
00118         virtual ~epdf() {};
00119 };
00120 
00121 
00123 //TODO Samplecond can be generalized
00124 
00125 class mpdf {
00126 protected:
00128         RV rv;
00130         RV rvc;
00132         epdf* ep;
00133 public:
00134 
00136 //      virtual fnc moment ( const int order = 1 );
00138         virtual vec samplecond ( vec &cond, double lik ) {return vec ( 0 );};
00139 
00140         virtual void condition ( const vec &cond ) {};
00141         
00142         virtual double evalcond (const vec &dt, const vec &cond ) {this->condition(cond);return ep->eval(dt);};
00143 
00145         virtual ~mpdf() {};
00146 
00148         mpdf ( const RV &rv0, const RV &rvc0 ) :rv ( rv0 ),rvc ( rvc0 ) {};
00149 };
00150 
00158 class DS {
00159 protected:
00161         RV Drv;
00163         RV Urv; //
00164 public:
00166         void getdata ( vec &dt );
00168         void getdata ( vec &dt, ivec &indeces );
00170         void write ( vec &ut );
00172         void write ( vec &ut, ivec &indeces );
00178         void linkrvs ( RV &drv, RV &urv );
00179 
00181         void step();
00182 
00183 };
00184 
00189 class BM {
00190 protected:
00192         RV rv;
00194  double ll;
00196         bool evalll;
00197 public:
00198 
00200         BM(const RV &rv0) :rv(rv0), ll ( 0 ),evalll ( true ) {//Fixme: test rv 
00201         };
00202 
00206         virtual void bayes ( const vec &dt ) = 0;
00208         void bayes ( mat Dt );
00210         virtual epdf& _epdf()=0;
00211 
00213         virtual ~BM() {};
00214 };
00215 
00225 class BMcond {
00226 protected:
00227         RV rvc;
00228 public:
00230         virtual void condition ( const vec &val ) =0;
00231         virtual ~BMcond(){};
00232 };
00233 
00234 #endif // BM_H

Generated on Thu Feb 28 16:54:40 2008 for mixpp by  doxygen 1.5.3