Changeset 660 for library/bdm/estim
- Timestamp:
- 10/15/09 00:04:30 (15 years ago)
- Location:
- library/bdm/estim
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/estim/arx.h
r649 r660 124 124 //!\name Access attributes 125 125 //!@{ 126 const egiw& posterior() const { 126 //! return correctly typed posterior (covariant return) 127 const egiw& posterior() const { 127 128 return est; 128 129 } … … 189 190 public: 190 191 ARXfrg():ARX(){}; 192 //! copy constructor 191 193 ARXfrg(const ARXfrg &A0):ARX(A0){}; 192 194 ARXfrg* _copy_() const {ARXfrg *A = new ARXfrg(*this); return A;} -
library/bdm/estim/kalman.h
r653 r660 54 54 public: 55 55 StateSpace() : dimx (0), dimy (0), dimu (0), A(), B(), C(), D(), Q(), R() {} 56 //!copy constructor 56 57 StateSpace(const StateSpace<sq_T> &S0) : dimx (S0.dimx), dimy (S0.dimy), dimu (S0.dimu), A(S0.A), B(S0.B), C(S0.C), D(S0.D), Q(S0.Q), R(S0.R) {} 58 //! set all matrix parameters 57 59 void set_parameters (const mat &A0, const mat &B0, const mat &C0, const mat &D0, const sq_T &Q0, const sq_T &R0); 60 //! validation 58 61 void validate(); 59 62 //! not virtual in this case … … 116 119 public: 117 120 Kalman<sq_T>() : BM(), StateSpace<sq_T>(), yrv(),urv(), _K(), est(new enorm<sq_T>){} 121 //! Copy constructor 118 122 Kalman<sq_T>(const Kalman<sq_T> &K0) : BM(K0), StateSpace<sq_T>(K0), yrv(K0.yrv),urv(K0.urv), _K(K0._K), est(new enorm<sq_T>(*K0.est)), fy(K0.fy){} 123 //!set statistics of the posterior 119 124 void set_statistics (const vec &mu0, const mat &P0) {est->set_parameters (mu0, P0); }; 125 //!set statistics of the posterior 120 126 void set_statistics (const vec &mu0, const sq_T &P0) {est->set_parameters (mu0, P0); }; 121 //! posterior127 //! return correctly typed posterior (covariant return) 122 128 const enorm<sq_T>& posterior() const {return *est.get();} 123 129 //! shared posterior … … 138 144 validate(); 139 145 } 146 //! validate object 140 147 void validate() { 141 148 StateSpace<sq_T>::validate(); … … 242 249 est->set_parameters (mu0, P0); 243 250 }; 251 //! access function 244 252 const mat _R() { 245 253 return est->_R().to_mat(); … … 371 379 enorm<chmat> est; 372 380 public: 381 //! set internal parameters 373 382 void set_parameters (Array<EKFCh*> A, int pol0 = 1) { 374 383 Models = A;//TODO: test if evalll is set … … 406 415 } 407 416 } 408 //! posterior density417 //! return correctly typed posterior (covariant return) 409 418 const enorm<chmat>& posterior() const { 410 419 return est; -
library/bdm/estim/mixtures.h
r565 r660 111 111 //! EM algorithm 112 112 void bayes ( const mat &dt ); 113 //! batch weighted Bayes rule 113 114 void bayesB ( const mat &dt, const vec &wData ); 114 115 double logpred ( const vec &dt ) const; 115 const epdf& posterior() const { 116 //! return correctly typed posterior (covariant return) 117 const eprod& posterior() const { 116 118 return *est; 117 119 } -
library/bdm/estim/particles.h
r653 r660 106 106 //!access function 107 107 vec& _lls() { return lls; } 108 //!access function 108 109 RESAMPLING_METHOD _resmethod() const { return resmethod; } 109 //! access function110 //! return correctly typed posterior (covariant return) 110 111 const eEmp& posterior() const {return est;} 111 112 … … 190 191 est.resample(ind,resmethod); 191 192 } 193 //! access function 192 194 Array<vec>& __samples(){return _samples;} 193 195 }; … … 203 205 class MPF : public BM { 204 206 protected: 207 //! particle filter on non-linear variable 205 208 shared_ptr<PF> pf; 209 //! Array of Bayesian models 206 210 Array<BM*> BMs; 207 211 … … 209 213 210 214 class mpfepdf : public epdf { 215 //! pointer to particle filter 211 216 shared_ptr<PF> &pf; 217 //! pointer to Array of BMs 212 218 Array<BM*> &BMs; 213 219 public: 220 //! constructor 214 221 mpfepdf (shared_ptr<PF> &pf0, Array<BM*> &BMs0): epdf(), pf(pf0), BMs(BMs0) { }; 215 222 //! a variant of set parameters - this time, parameters are read from BMs and pf … … 300 307 //! Default constructor. 301 308 MPF () : jest (pf,BMs) {}; 309 //! set all parameters at once 302 310 void set_parameters ( shared_ptr<mpdf> par0, shared_ptr<mpdf> obs0, int n0, RESAMPLING_METHOD rm = SYSTEMATIC ) { 303 311 pf->set_model ( par0, obs0); … … 305 313 BMs.set_length ( n0 ); 306 314 } 315 //! set a prototype of BM, copy it to as many times as there is particles in pf 307 316 void set_BM ( const BM &BMcond0 ) { 308 317 … … 313 322 for ( int i = 0; i < n; i++ ) { 314 323 BMs ( i ) = BMcond0._copy_(); 315 BMs ( i )->condition ( pf->posterior()._sample ( i ) );316 324 } 317 325 }; … … 374 382 } 375 383 jest.read_parameters(); 384 for ( int i = 0; i < pf->__w().length(); i++ ) { 385 BMs ( i )->condition ( pf->posterior()._sample ( i ) ); 386 } 376 387 } 377 388