- Timestamp:
- 11/04/09 22:54:58 (15 years ago)
- Location:
- library
- Files:
-
- 1 removed
- 11 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r693 r700 53 53 id = iter->second; 54 54 if (size>0){ 55 bdm_assert ( SIZES ( id ) == size, "RV " + name + " of different size already exists" );55 bdm_assert ( SIZES ( id ) == size, "RV " + name + " of size " + num2str(SIZES(id)) + " exists, requested size " + num2str(size) + "can not be assigned" ); 56 56 } 57 57 } -
library/bdm/base/bdmbase.h
r693 r700 266 266 //! Minimum time-offset 267 267 int mint() const { 268 return times.length()>0 ? min (times) : 0; 268 return times.length()>0 ? min (times) : 0; 269 } 270 //! Minimum time-offset of ids of given RVs 271 int mint(const RV &rv) const { 272 bvec belong=zeros_b(len); 273 for (int r=0; r<rv.length(); r++){ 274 belong = belong | (ids == rv.id(r)); 275 } 276 return times.length()>0 ? min (times(belong)) : 0; 269 277 } 270 278 //!@} … … 598 606 logrec->L.logit( logrec->ids(0), mean() ); 599 607 } 600 if (log_level> 2) {608 if (log_level>1) { 601 609 vec lb; vec ub; 602 610 qbounds(lb,ub); … … 913 921 //establish c2c connection 914 922 rvc.dataind ( rvc_up, c2c_lo, c2c_up ); 915 bdm_assert_debug ( c2c_lo.length() + v2c_lo.length() == condsize, "cond is not fully given" );923 // bdm_assert_debug ( c2c_lo.length() + v2c_lo.length() == condsize, "cond is not fully given" ); 916 924 } 917 925 … … 919 927 vec get_cond ( const vec &val_up, const vec &cond_up ) { 920 928 vec tmp ( condsize ); 921 set_subvector ( tmp, v2c_lo, val_up ( v2c_up ) ); 922 set_subvector ( tmp, c2c_lo, cond_up ( c2c_up ) ); 929 fill_cond (val_up, cond_up, tmp ); 923 930 return tmp; 931 } 932 //! fill condition 933 void fill_cond ( const vec &val_up, const vec &cond_up, vec& cond_out){ 934 bdm_assert_debug(cond_out.length()>=condsize,"dl.fill_cond: cond_out is too small"); 935 set_subvector ( cond_out, v2c_lo, val_up ( v2c_up ) ); 936 set_subvector ( cond_out, c2c_lo, cond_up ( c2c_up ) ); 924 937 } 925 938 //! Fill … … 1077 1090 1078 1091 BM() : yrv(),dimy(0),rvc(),dimc(0), ll ( 0 ), evalll ( true ) { }; 1079 BM ( const BM &B ) : yrv ( B.yrv ), dimy(B.dimy), rvc ( B.rvc), ll ( B.ll ), evalll ( B.evalll ) {}1092 // BM ( const BM &B ) : yrv ( B.yrv ), dimy(B.dimy), rvc ( B.rvc ),dimc(B.dimc), ll ( B.ll ), evalll ( B.evalll ) {} 1080 1093 //! \brief Copy function required in vectors, Arrays of BM etc. Have to be DELETED manually! 1081 1094 //! Prototype: \code BM* _copy_() const {return new BM(*this);} \endcode -
library/bdm/base/datasources.h
r697 r700 132 132 dt = zeros(iepdf->dimension()); 133 133 dtsize=dt.length(); 134 ytsize=dt.length(); 134 135 set_drv(iepdf->_rv(),RV()); 135 136 utsize =0; … … 365 366 class = "stateDS"; 366 367 //Internal model 367 IM = { type = " mpdf-offspring"; };368 IM = { type = "pdf-offspring"; }; 368 369 //Observation model 369 OM = { type = " mpdf-offspring"; }370 OM = { type = "pdf-offspring"; } 370 371 //initial state 371 372 x0 = [...]; //vector of data -
library/bdm/estim/arx.cpp
r679 r700 2 2 namespace bdm { 3 3 4 void ARX::bayes_weighted ( const vec &yt, const vec &cond, const double w ) { 4 void ARX::bayes_weighted ( const vec &yt, const vec &cond, const double w ) { 5 6 bdm_assert_debug(yt.length()>=dimy,"ARX::bayes yt is smaller then dimc"); 7 bdm_assert_debug(cond.length()>=dimc,"ARX::bayes cond is smaller then dimc"); 5 8 double lnc; 6 9 //cache -
library/bdm/estim/arx.h
r679 r700 54 54 //! \name Constructors 55 55 //!@{ 56 ARX ( const double frg0 = 1.0 ) : BMEF ( frg0 ), have_constant(true), dyad(), est() {};57 ARX ( const ARX &A0 ) : BMEF (A0 .frg), have_constant(A0.have_constant), dyad(A0.dyad),est(est) { };56 ARX ( const double frg0 = 1.0 ) : BMEF ( frg0 ), have_constant(true), dyad(), est(), alter_est() {}; 57 ARX ( const ARX &A0 ) : BMEF (A0), have_constant(A0.have_constant), dyad(A0.dyad),est(A0.est),alter_est(A0.alter_est) { }; 58 58 ARX* _copy_() const; 59 59 void set_parameters ( double frg0 ) { … … 167 167 /*! ARX model conditined by knowledge of the forgetting factor 168 168 \f[ f(\theta| d_1 \ldots d_t , \phi_t) \f] 169 170 The symbol \f$ \phi \f$ is assumed to be the last of the conditioning variables. 169 171 */ 170 172 class ARXfrg : public ARX{ … … 174 176 ARXfrg(const ARXfrg &A0):ARX(A0){}; 175 177 ARXfrg* _copy_() const {ARXfrg *A = new ARXfrg(*this); return A;} 176 void condition(const vec &val){ 177 frg = val(0); 178 179 void bayes(const vec &val, const vec &cond){ 180 frg = cond(dimc-1); // last in cond is phi 181 ARX::bayes(val,cond); 182 } 183 void validate() { 184 ARX::validate(); 185 rvc.add(RV("{phi }",vec_1(1))); 186 dimc +=1; 178 187 } 179 188 }; -
library/bdm/estim/particles.cpp
r679 r700 78 78 int n=pf->__w().length(); 79 79 vec &lls = pf->_lls(); 80 Array<vec> &samples=pf->__samples(); 80 81 81 82 // generate samples - time step … … 84 85 #pragma parallel for 85 86 for ( i = 0; i < n; i++ ) { 86 BMs(i) -> bayes(this2bm.pushdown(yt), this2bm.get_cond(yt,cond)); 87 vec bm_cond(BMs(i)->dimensionc()); 88 this2bm.fill_cond(yt,cond, bm_cond); 89 pf2bm.filldown(samples(i), bm_cond); 90 BMs(i) -> bayes(this2bm.pushdown(yt), bm_cond); 87 91 lls ( i ) += BMs(i)->_ll(); 88 92 } -
library/bdm/estim/particles.h
r693 r700 157 157 res_threshold=0.5; 158 158 } 159 validate();159 //validate(); 160 160 } 161 161 //! load prior information from set and set internal structures accordingly … … 177 177 178 178 void validate(){ 179 bdm_assert(par,"PF::parameter_pdf not specified."); 179 180 n=_w.length(); 180 181 lls=zeros(n); 182 181 183 if (par->_rv()._dsize()>0) { 182 184 bdm_assert(par->_rv()._dsize()==est.dimension(),"Mismatch of RV and dimension of posterior" ); … … 301 303 //! datalink from global yt and cond (Up) to PFs yt and cond (Down) 302 304 datalink_m2m this2pf; 305 //!datalink from PF part to BM 306 datalink_part pf2bm; 303 307 304 308 public: … … 367 371 } 368 372 //set drv 373 //??set_yrv(concat(BM0->_yrv(),u) ); 374 set_yrv(BM0->_yrv() ); 375 rvc = BM0->_rvc().subt(par->_rv()); 369 376 //find potential input - what remains in rvc when we subtract rv 370 RV u = par->_rvc().remove_time().subt( par->_rv() ); 371 set_yrv(concat(BM0->_yrv(),u) ); 377 RV u = par->_rvc().subt( par->_rv().copy_t(-1) ); 378 rvc.add(u); 379 dimc = rvc._dsize(); 372 380 validate(); 373 381 } 374 382 void validate(){ 375 383 try{ 376 pf->validate();384 pf->validate(); 377 385 } catch (std::exception &e){ 378 386 throw UIException("Error in PF part of MPF:"); … … 380 388 jest.read_parameters(); 381 389 this2bm.set_connection(BMs(0)->_yrv(), BMs(0)->_rvc(), yrv, rvc); 382 this2bm.set_connection(pf->_yrv(), pf->_rvc(), yrv, rvc); 390 this2pf.set_connection(pf->_yrv(), pf->_rvc(), yrv, rvc); 391 pf2bm.set_connection(BMs(0)->_rvc(), pf->posterior()._rv()); 383 392 } 384 393 -
library/bdm/math/square_mat.h
r619 r700 221 221 //! print full matrix 222 222 friend std::ostream &operator<< ( std::ostream &os, const fsqmat &sq ); 223 //!access function 224 mat & _M ( ) {return M;}; 223 225 224 226 }; -
library/bdm/mex/config2mxstruct.h
r665 r700 2 2 #define CFGSTR_H 3 3 4 #include "../base/libconfig/lib config.h++"4 #include "../base/libconfig/lib/libconfig.h++" 5 5 #include <itpp/itbase.h> 6 6 #include <itpp/itmex.h> -
library/bdm/mex/mex_parser.h
r691 r700 3 3 4 4 5 #include " ../base/libconfig/lib/lib/libconfig.h++"5 #include "base/libconfig/lib/libconfig.h++" 6 6 #include <itpp/itbase.h> 7 7 #include <itpp/itmex.h> -
library/tests/CMakeLists.txt
r693 r700 41 41 # using UnitTest++ 42 42 43 SET(unit_test_configurations mepdf.cfgegiw.cfg mlnorm.cfg edirich.cfg mprod.cfg generator.cfg epdfds.cfg pdfds.cfg test_user_info_input.cfg merger.cfg erroneous.cfg egamma.cfg test_user_info_external.cfg merger_error.cfg mgamma.cfg enorm.cfg)43 SET(unit_test_configurations egiw.cfg mlnorm.cfg edirich.cfg mprod.cfg generator.cfg epdfds.cfg pdfds.cfg test_user_info_input.cfg merger.cfg erroneous.cfg egamma.cfg test_user_info_external.cfg merger_error.cfg mgamma.cfg enorm.cfg) 44 44 45 45 add_executable(testsuite arx_straux_test.cpp datalink_test.cpp datasource_test.cpp egiw_test.cpp emix_test.cpp epdf_test.cpp logger_test.cpp LQG_test.cpp merger_test.cpp