Changeset 267 for bdm/stat/libDS.h

Show
Ignore:
Timestamp:
02/11/09 14:15:05 (15 years ago)
Author:
smidl
Message:

samplecond modification

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/stat/libDS.h

    r265 r267  
    7373                int L_theta; 
    7474                int L_R; 
    75                 public: 
     75        public: 
    7676                void getdata ( vec &dt ) { 
    7777                        it_assert_debug ( dt.length() ==Drv.count(),"ArxDS" ); 
     
    104104                        mat &A =model._A(); 
    105105                        mat R =model._R(); 
    106                         if ( opt_L_theta ) {L_theta=L.add ( RV("{theta }", vec_1(A.rows() *A.cols())),"t" );} 
    107                         if ( opt_L_theta ) {L_R=L.add ( RV("{R }", vec_1(R.rows() *R.cols())),"r" );} 
     106                        if ( opt_L_theta ) {L_theta=L.add ( RV ( "{theta }", vec_1 ( A.rows() *A.cols() ) ),"t" );} 
     107                        if ( opt_L_theta ) {L_R=L.add ( RV ( "{R }", vec_1 ( R.rows() *R.cols() ) ),"r" );} 
    108108                } 
    109109                virtual void logit ( logger &L ) { 
     
    126126 
    127127        }; 
     128 
     129        class stateDS : public DS { 
     130        protected: 
     131                //!conditional pdf of the state evolution \f$ f(x_t|x_{t-1}) \f$ 
     132                mpdf* IM; 
     133                //!conditional pdf of the observations \f$ f(d_t|x_t) \f$ 
     134                mpdf* OM; 
     135                //! result storage 
     136                vec dt; 
     137                //! state storage 
     138                vec xt; 
     139                //! input storage 
     140                vec ut; 
     141                //! Logger 
     142                int L_xt; 
     143        public: 
     144                void getdata ( vec &dt0 ) {dt0=dt;} 
     145                void getdata ( vec &dt0, const ivec &indeces ) {dt0=dt ( indeces );} 
     146 
     147                stateDS ( mpdf* IM0, mpdf* OM0, RV &Urv0 ) :DS ( OM0->_rv(),Urv0 ),IM ( IM0 ),OM ( OM0 ), 
     148                                dt ( OM0->_rv().count() ), xt ( IM0->_rv().count() ), ut ( Urv0.count() ) {} 
     149                ~stateDS() {delete IM; delete OM;} 
     150                virtual void step() { 
     151                        double tmp; 
     152                        xt=IM->samplecond(concat ( xt,ut )); 
     153                        dt=OM->samplecond(concat ( xt,ut )); 
     154                }; 
     155                 
     156                virtual void log_add ( logger &L ) { 
     157                        DS::log_add ( L ); 
     158                        L_xt=L.add(IM->_rv(),"true"); 
     159                } 
     160                virtual void logit ( logger &L ) { 
     161                        DS::logit ( L ); 
     162                        L.logit ( L_xt,xt); 
     163                } 
     164 
     165        }; 
     166 
    128167}; //namespace 
    129168