Legend:
- Unmodified
- Added
- Removed
-
bdm/estim/arx.h
r270 r271 31 31 \f] 32 32 33 Extension for time-variant parameters \f$\theta_t,r_t\f$ may be achived using exponential forgetting (Kulhavy and Zarrop, 1993). In such a case, the forgetting factor \c frg \f$\in <0,1>\f$ should be given in the constructor. Time-invariant parameters are estimated for \c frg = 1. 33 See \ref tut_arx for mathematical treatment. 34 35 The easiest way how to use the class is: 36 \include arx_simple.cpp 37 34 38 */ 35 39 class ARX: public BMEF { … … 89 93 //!@{ 90 94 const egiw* _e() const {return &est ;}; 91 const egiw& _epdf() const {return est;}95 const egiw& posterior() const {return est;} 92 96 //!@} 93 97 -
bdm/estim/libKF.cpp
r270 r271 6 6 using std::endl; 7 7 8 KalmanFull::KalmanFull ( mat A0, mat B0, mat C0, mat D0, mat R0, mat Q0, mat P0, vec mu0 ) {8 KalmanFull::KalmanFull ( mat A0, mat B0, mat C0, mat D0, mat Q0, mat R0, mat P0, vec mu0 ) { 9 9 dimx = A0.rows(); 10 10 dimu = B0.cols(); … … 15 15 it_assert_debug ( C0.cols() ==dimx, "KalmanFull: C is not square" ); 16 16 it_assert_debug ( ( D0.rows() ==dimy ) || ( D0.cols() ==dimu ), "KalmanFull: D is not compatible" ); 17 it_assert_debug ( ( Q0.cols() ==dimx ) || ( Q0.rows() ==dimx ), "KalmanFull: Q is not compatible" ); 17 18 it_assert_debug ( ( R0.cols() ==dimy ) || ( R0.rows() ==dimy ), "KalmanFull: R is not compatible" ); 18 it_assert_debug ( ( Q0.cols() ==dimx ) || ( Q0.rows() ==dimx ), "KalmanFull: Q is not compatible" );19 19 20 20 A = A0; … … 116 116 117 117 118 void KalmanCh::set_parameters ( const mat &A0,const mat &B0,const mat &C0,const mat &D0,const chmat & R0,const chmat &Q0 ) {119 120 ( ( Kalman<chmat>* ) this )->set_parameters ( A0,B0,C0,D0, R0,Q0 );118 void KalmanCh::set_parameters ( const mat &A0,const mat &B0,const mat &C0,const mat &D0,const chmat &Q0,const chmat &R0 ) { 119 120 ( ( Kalman<chmat>* ) this )->set_parameters ( A0,B0,C0,D0,Q0,R0 ); 121 121 // Cholesky special! 122 preA.clear(); 122 preA=zeros(dimy+dimx+dimx,dimy+dimx); 123 // preA.clear(); 123 124 preA.set_submatrix ( 0,0,R._Ch() ); 124 125 preA.set_submatrix ( dimy+dimx,dimy,Q._Ch() ); -
bdm/estim/libKF.h
r270 r271 109 109 Kalman ( const Kalman<sq_T> &K0 ); 110 110 //! Set parameters with check of relevance 111 void set_parameters ( const mat &A0,const mat &B0,const mat &C0,const mat &D0,const sq_T & R0,const sq_T &Q0 );111 void set_parameters ( const mat &A0,const mat &B0,const mat &C0,const mat &D0,const sq_T &Q0,const sq_T &R0 ); 112 112 //! Set estimate values, used e.g. in initialization. 113 113 void set_est ( const vec &mu0, const sq_T &P0 ) { … … 121 121 void bayes ( const vec &dt ); 122 122 //!access function 123 const epdf& _epdf() const {return est;}123 const epdf& posterior() const {return est;} 124 124 const enorm<sq_T>* _e() const {return &est;} 125 125 //!access function … … 130 130 131 131 /*! \brief Kalman filter in square root form 132 133 Trivial example: 134 \include kalman_simple.cpp 135 132 136 */ 133 137 class KalmanCh : public Kalman<chmat>{ … … 142 146 KalmanCh ():Kalman<chmat>(),preA(),postA(){}; 143 147 //! Set parameters with check of relevance 144 void set_parameters ( const mat &A0,const mat &B0,const mat &C0,const mat &D0,const chmat & R0,const chmat &Q0 );145 void set_ est( const vec &mu0, const chmat &P0 ) {148 void set_parameters ( const mat &A0,const mat &B0,const mat &C0,const mat &D0,const chmat &Q0,const chmat &R0 ); 149 void set_statistics ( const vec &mu0, const chmat &P0 ) { 146 150 est.set_parameters ( mu0,P0 ); 147 151 }; … … 187 191 void set_est (vec mu0, mat P0){mu=mu0;P=P0;}; 188 192 //!dummy! 189 const epdf& _epdf()const{return E;};193 const epdf& posterior()const{return E;}; 190 194 const enorm<fsqmat>* _e()const{return &E;}; 191 195 const mat _R(){return P;} … … 281 285 282 286 template<class sq_T> 283 void Kalman<sq_T>::set_parameters ( const mat &A0,const mat &B0, const mat &C0, const mat &D0, const sq_T &R0, const sq_T &Q0 ) { 287 void Kalman<sq_T>::set_parameters ( const mat &A0,const mat &B0, const mat &C0, const mat &D0, const sq_T &Q0, const sq_T &R0 ) { 288 dimx = A0.rows(); 289 dimy = C0.rows(); 290 dimu = B0.cols(); 291 284 292 it_assert_debug ( A0.cols() ==dimx, "Kalman: A is not square" ); 285 293 it_assert_debug ( B0.rows() ==dimx, "Kalman: B is not compatible" ); -
bdm/estim/libPF.h
r270 r271 122 122 for ( int i=0;i<n;i++ ) { 123 123 Bms[i] = new BM_T ( BMcond0 ); //copy constructor 124 const epdf& pom=Bms[i]-> _epdf();124 const epdf& pom=Bms[i]->posterior(); 125 125 jest.set_elements ( i,1.0/n,&pom ); 126 126 } … … 131 131 132 132 void bayes ( const vec &dt ); 133 const epdf& _epdf() const {return jest;}133 const epdf& posterior() const {return jest;} 134 134 const epdf* _e() const {return &jest;} //Fixme: is it useful? 135 135 //! Set postrior of \c rvc to samples from epdf0. Statistics of Bms are not re-computed! Use only for initialization! … … 195 195 delete Bms[i]; 196 196 Bms[i] = new BM_T ( *Bms[ind ( i ) ] ); //copy constructor 197 const epdf& pom=Bms[i]-> _epdf();197 const epdf& pom=Bms[i]->posterior(); 198 198 jest.set_elements ( i,1.0/n,&pom ); 199 199 } -
bdm/estim/merger.h
r270 r271 81 81 void merge ( const epdf* g0 ); 82 82 //!Create a mixture density, make sure to call init() before the first call 83 void merge () {merge ( & ( Mix. _epdf() ) );};83 void merge () {merge ( & ( Mix.posterior() ) );}; 84 84 85 85 //! Merge log-likelihood values … … 87 87 //! sample from merged density 88 88 //! weight w is a 89 vec sample ( ) const { return Mix. _epdf().sample();}89 vec sample ( ) const { return Mix.posterior().sample();} 90 90 double evallog ( const vec &dt ) const { 91 91 vec dtf=ones ( dt.length() +1 ); -
bdm/estim/mixef.cpp
r270 r271 124 124 double MixEF::logpred ( const vec &dt ) const { 125 125 126 vec w=weights. _epdf().mean();126 vec w=weights.posterior().mean(); 127 127 double exLL=0.0; 128 128 for ( int i=0;i<n;i++ ) { … … 137 137 emix* tmp; 138 138 tmp = new emix ( ); 139 tmp->set_parameters ( weights. _epdf().mean(), pC, false );139 tmp->set_parameters ( weights.posterior().mean(), pC, false ); 140 140 tmp->ownComs(); 141 141 return tmp; -
bdm/estim/mixef.h
r270 r271 59 59 for ( int i=0;i<Coms.length();i++ ) { 60 60 // it_assert_debug(!x,"MixEF::MixEF : Incompatible components"); 61 epdfs ( i ) =& ( Coms ( i )-> _epdf() );61 epdfs ( i ) =& ( Coms ( i )->posterior() ); 62 62 } 63 63 // last in the product is the weight 64 epdfs ( n ) =& ( weights. _epdf() );64 epdfs ( n ) =& ( weights.posterior() ); 65 65 est = new eprod ( epdfs ); 66 66 } … … 104 104 void bayesB ( const mat &dt, const vec &wData ); 105 105 double logpred ( const vec &dt ) const; 106 const epdf& _epdf() const {return *est;}106 const epdf& posterior() const {return *est;} 107 107 const eprod* _e() const {return est;} 108 108 emix* epredictor() const;