| 286 |   |           | 
                      
                      
                        |   | 286 |   | 
                      
                        |   | 287 | /*! \brief ARX model with fixed-length window - old entries are removed  | 
                      
                        |   | 288 |  * \f[ f(    heta| d_1 \ldots d_t) \f]  | 
                      
                        |   | 289 |  *   | 
                      
                        |   | 290 |  */  | 
                      
                        |   | 291 | class ARXwin : public ARX {  | 
                      
                        |   | 292 | protected:  | 
                      
                        |   | 293 |         mat Y;  | 
                      
                        |   | 294 |         mat Cond;  | 
                      
                        |   | 295 |           | 
                      
                        |   | 296 |         int win_length;  | 
                      
                        |   | 297 |         ldmat V0;  | 
                      
                        |   | 298 |         double nu0;  | 
                      
                        |   | 299 | public:  | 
                      
                        |   | 300 |         ARXwin() : ARX() {};  | 
                      
                        |   | 301 |         //! copy constructor  | 
                      
                        |   | 302 |         void set_parameters(const int win_length0){   | 
                      
                        |   | 303 |                 win_length=win_length0;  | 
                      
                        |   | 304 |         }  | 
                      
                        |   | 305 |         ARXwin ( const ARXwin &A0 ) : ARX(A0), Y( A0.Y), Cond(A0.Cond) {};  | 
                      
                        |   | 306 |           | 
                      
                        |   | 307 |         virtual ARXwin* _copy() const {  | 
                      
                        |   | 308 |                 ARXwin *A = new ARXwin ( *this );  | 
                      
                        |   | 309 |                 return A;  | 
                      
                        |   | 310 |         }  | 
                      
                        |   | 311 |           | 
                      
                        |   | 312 |         void bayes ( const vec &val, const vec &cond ) {  | 
                      
                        |   | 313 |                 // fill window  | 
                      
                        |   | 314 |                 Y.append_col(val);  | 
                      
                        |   | 315 |                 Cond.append_col(cond);            | 
                      
                        |   | 316 |                 if (Y.cols()>win_length){  | 
                      
                        |   | 317 |                         // shift the buffer  | 
                      
                        |   | 318 |                         Y=Y.get_cols(1,Y.cols()-1);  | 
                      
                        |   | 319 |                         Cond=Cond.get_cols(1,Cond.cols()-1);  | 
                      
                        |   | 320 |                 }  | 
                      
                        |   | 321 |                   | 
                      
                        |   | 322 |                 est._V()=V0;  | 
                      
                        |   | 323 |                 est._nu()=nu0;  | 
                      
                        |   | 324 |                 for ( int t = 0; t < Y.cols(); t++ ) {  | 
                      
                        |   | 325 |                         ARX::bayes ( Y.get_col ( t ), Cond.get_col ( t ) );  | 
                      
                        |   | 326 |                 }  | 
                      
                        |   | 327 |                   | 
                      
                        |   | 328 |         }  | 
                      
                        |   | 329 |         void from_setting(const Setting &set){  | 
                      
                        |   | 330 |                 ARX::from_setting(set);  | 
                      
                        |   | 331 |                 UI::get(win_length,set,"win_length",UI::compulsory);  | 
                      
                        |   | 332 |         }  | 
                      
                        |   | 333 |         void validate() {  | 
                      
                        |   | 334 |                 ARX::validate();  | 
                      
                        |   | 335 |                 V0=est._V();  | 
                      
                        |   | 336 |                 nu0=est._nu();  | 
                      
                        |   | 337 |         }  | 
                      
                        |   | 338 | };  | 
                      
                        |   | 339 |           | 
                      
                        |   | 340 | UIREGISTER ( ARXwin );  | 
                      
                        |   | 341 |           | 
                      
                        |   | 342 |   |