- Timestamp:
- 09/17/10 14:35:13 (14 years ago)
- Location:
- library/bdm
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.cpp
r1165 r1192 210 210 rv.dataind ( rv_up, v2v_down, v2v_up ); 211 211 downsize = v2v_down.length(); 212 upsize = v2v_up.length();212 upsize = rv_up._dsize();//v2v_up.length(); 213 213 } 214 214 -
library/bdm/base/bdmbase.h
r1165 r1192 1036 1036 }; 1037 1037 void connect(const RV &vecrv, const RV & vec1) { 1038 bdm_assert(vecrv._dsize()==length(),"Description of this vector, "+ vecrv.to_string() +" does not math it length: " + num2str(length())); 1038 1039 bdm_assert(vecrv._dsize()==length(),"Description of this vector, "+ vecrv.to_string() +" does not math it length: " + num2str(length())); 1039 1040 dl.set_connection(vecrv,vec1); 1041 vecfromlen=vec1._dsize(); 1040 1042 bdm_assert(dl._downsize()==length(), "Rv of this vector, "+vecrv.to_string() +" was not found in given rv: "+vec1.to_string()); 1041 1043 }; 1044 void push_to(vec &v_up){ 1045 dl.pushup(*this,v_up); 1046 } 1047 datalink_part& _dl() {return dl;} 1042 1048 }; 1043 1049 … … 1325 1331 1326 1332 //! Sample from predictor(cond). Implemented as sampling the joint density \f$ f(y_t, \theta_t) \f$ and discarding the sample of \f$ \theta_t \f$. 1327 virtual vec samplepred(const vec &cond=empty_vec) constNOT_IMPLEMENTED(empty_vec);1333 virtual vec samplepred(const vec &cond=empty_vec) NOT_IMPLEMENTED(empty_vec); 1328 1334 1329 1335 //! Matrix version of logpred -
library/bdm/estim/arx.cpp
r1176 r1192 71 71 } 72 72 73 vec ARX::samplepred(const vec &cond) const{73 vec ARX::samplepred(const vec &cond) { 74 74 mat M; 75 75 chmat R; -
library/bdm/estim/arx.h
r1189 r1192 89 89 }; 90 90 double logpred ( const vec &yt, const vec &cond ) const; 91 vec samplepred ( const vec &cond ) const;91 vec samplepred ( const vec &cond ) ; 92 92 void flatten ( const BMEF* B , double weight ); 93 93 //! Conditioned version of the predictor -
library/bdm/estim/particles.h
r1187 r1192 33 33 MarginalizedParticleBase ∓ 34 34 public: 35 36 35 eprod_2(MarginalizedParticleBase &m):mp(m) {} 36 const epdf* factor(int i) const { 37 37 return (i==0) ? &mp.bm->posterior() : &mp.est_emp; 38 38 } … … 622 622 }; 623 623 UIREGISTER(NoiseParticleX); 624 624 625 625 626 /*! Marginalized particle for state-space models with unknown parameters of distribuution of residues on \f$v_t\f$ and \f$ w_t \f$. -
library/bdm/stat/emix.h
r1170 r1192 293 293 virtual const int no_factors() const NOT_IMPLEMENTED(0); 294 294 //! Default constructor 295 eprod_base () : dls (0) {}; 296 //! Set internal 295 eprod_base () : dls (0) {}; 296 eprod_base (const eprod_base &ep0) : dls (ep0.dls) {}; 297 //! Set internal 297 298 vec mean() const; 298 299 … … 449 450 ProdBMBase & pb; 450 451 public : 451 452 452 eprod_bm(ProdBMBase &pb0): pb(pb0) {} 453 const epdf* factor(int i ) const { 453 454 return &(pb.bm(i)->posterior()); 454 455 } … … 458 459 } est; 459 460 public: 460 ProdBMBase():est(*this) {} 461 virtual BM* bm(int i) NOT_IMPLEMENTED(NULL); 461 ProdBMBase():BM(),est(*this) {} 462 ProdBMBase(const ProdBMBase &p0):BM(p0),bm_yt(p0.bm_yt),bm_cond(p0.bm_cond),est(*this) { 463 est.validate(); 464 } 465 virtual BM* bm(int i) NOT_IMPLEMENTED(NULL); 462 466 virtual int no_bms() const { 463 467 return 0; … … 496 500 497 501 for (int i=0; i<no_bms(); i++) { 502 bm_yt(i).set_length(bm(i)->dimensiony()); 498 503 bm_yt(i).connect(bm(i)->_yrv(), yrv); 499 bm_cond(i).connect(bm(i)->_rvc(), yrv, rvc); 504 bm_cond(i).set_length(bm(i)->dimensionc()); 505 bm_cond(i).connect(bm(i)->_rvc(), yrv, rvc); 500 506 } 501 507 } … … 506 512 bm_cond(i).update(dt,cond); 507 513 bm(i)->bayes(bm_yt(i), bm_cond(i)); 508 } 509 } 510 514 ll+=bm(i)->_ll(); 515 } 516 } 517 vec samplepred( const vec &cond) { 518 vec samp=zeros(dimy); 519 520 for(int i=0; i<no_bms(); i++) { 521 bm_cond(i).update(samp,cond); 522 vec yi=bm(i)->samplepred(bm_cond(i)); 523 bm_yt(i)._dl().pushup(samp,yi); 524 } 525 return samp; 526 } 527 511 528 }; 512 529 … … 515 532 Array<shared_ptr<BM> > BMs; 516 533 public: 534 ProdBM():ProdBMBase(),BMs(){}; 535 ProdBM(const ProdBM &p0):ProdBMBase(p0),BMs(p0.BMs){est.validate();}; 536 ProdBM* _copy() const {return new ProdBM(*this);} 517 537 virtual BM* bm(int i) { 518 538 return BMs(i).get(); … … 529 549 UI::save(BMs,set,"BMs"); 530 550 } 531 532 551 }; 533 552 UIREGISTER(ProdBM); -
library/bdm/stat/exp_family.cpp
r1189 r1192 160 160 vec egiw::est_theta() const { 161 161 if ( dimx == 1 ) { 162 if (dimc<1) return empty_vec; 163 162 164 const mat &L = V._L(); 163 165 int end = L.rows() - 1;