Changeset 693
- Timestamp:
- 11/02/09 17:27:29 (15 years ago)
- Location:
- library
- Files:
-
- 26 modified
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/CMakeLists.txt
r692 r693 18 18 IF(WIN32) 19 19 SET(bdm_support ${bdm_support} dirent.c dirent.h) 20 ADD_DEFINITIONS(-DLIBCONFIG_STATIC -DLIBCONFIGXX_STATIC)21 20 ENDIF() 22 21 -
library/bdm/base/bdmbase.cpp
r690 r693 146 146 } 147 147 148 shared_ptr< mpdf> epdf::condition ( const RV &rv ) const {148 shared_ptr<pdf> epdf::condition ( const RV &rv ) const { 149 149 bdm_warning ( "Not implemented" ); 150 return shared_ptr< mpdf>();150 return shared_ptr<pdf>(); 151 151 } 152 152 … … 180 180 } 181 181 182 mat mpdf::samplecond_m ( const vec &cond, int N ) {182 mat pdf::samplecond_m ( const vec &cond, int N ) { 183 183 mat M ( dimension(), N ); 184 184 for ( int i = 0; i < N; i++ ) { … … 189 189 } 190 190 191 void mpdf::from_setting ( const Setting &set ) {191 void pdf::from_setting ( const Setting &set ) { 192 192 shared_ptr<RV> r = UI::build<RV> ( set, "rv", UI::optional ); 193 193 if ( r ) { … … 373 373 } 374 374 375 RV get_composite_rv ( const Array<shared_ptr< mpdf> > &mpdfs,375 RV get_composite_rv ( const Array<shared_ptr<pdf> > &pdfs, 376 376 bool checkoverlap ) { 377 377 RV rv; //empty rv 378 378 bool rvaddok; 379 for ( int i = 0; i < mpdfs.length(); i++ ) {380 rvaddok = rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs.381 // If rvaddok==false, mpdfs overlap => assert error.382 bdm_assert_debug ( rvaddok || !checkoverlap, "mprod::mprod() input mpdfs overlap in rv!" );379 for ( int i = 0; i < pdfs.length(); i++ ) { 380 rvaddok = rv.add ( pdfs ( i )->_rv() ); //add rv to common rvs. 381 // If rvaddok==false, pdfs overlap => assert error. 382 bdm_assert_debug ( rvaddok || !checkoverlap, "mprod::mprod() input pdfs overlap in rv!" ); 383 383 } 384 384 -
library/bdm/base/bdmbase.h
r690 r693 386 386 387 387 //! Conditional probability density, e.g. modeling \f$ f( x | y) \f$, where \f$ x \f$ is random variable, \c rv, and \f$ y \f$ is conditioning variable, \c rvc. 388 class mpdf : public root {388 class pdf : public root { 389 389 protected: 390 390 //!dimension of the condition … … 403 403 //! @{ 404 404 405 mpdf() : dimc ( 0 ), rvc(), dim(0), rv() { }406 407 mpdf ( const mpdf &m ) : dimc ( m.dimc ), rvc ( m.rvc ), dim( m.dim), rv( m.rv ) { }405 pdf() : dimc ( 0 ), rvc(), dim(0), rv() { } 406 407 pdf ( const pdf &m ) : dimc ( m.dimc ), rvc ( m.rvc ), dim( m.dim), rv( m.rv ) { } 408 408 409 409 //! copy of the current object - make sure to implement 410 virtual mpdf* _copy_() const {return new mpdf(*this);}410 virtual pdf* _copy_() const {return new pdf(*this);} 411 411 //!@} 412 412 … … 467 467 //! Load from structure with elements: 468 468 //! \code 469 //! { class = " mpdf_offspring",469 //! { class = "pdf_offspring", 470 470 //! rv = {class="RV", names=(...),}; // RV describing meaning of random variable 471 471 //! rvc= {class="RV", names=(...),}; // RV describing meaning of random variable in condition … … 491 491 //!@} 492 492 }; 493 SHAREDPTR ( mpdf );493 SHAREDPTR ( pdf ); 494 494 495 495 //! Probability density function with numerical statistics, e.g. posterior density. 496 class epdf : public mpdf {496 class epdf : public pdf { 497 497 498 498 public: … … 509 509 @{*/ 510 510 epdf() {}; 511 epdf ( const epdf &e ) : mpdf(e) {};511 epdf ( const epdf &e ) : pdf(e) {}; 512 512 void set_parameters ( int dim0 ) { 513 513 dim = dim0; … … 542 542 543 543 //! Return conditional density on the given RV, the remaining rvs will be in conditioning 544 virtual shared_ptr< mpdf> condition ( const RV &rv ) const;544 virtual shared_ptr<pdf> condition ( const RV &rv ) const; 545 545 546 546 //! Return marginal density on the given RV, the remainig rvs are intergrated out … … 633 633 SHAREDPTR ( epdf ); 634 634 635 //! Mpdf with internal epdf that is modified by function \c condition635 //! pdf with internal epdf that is modified by function \c condition 636 636 template <class EPDF> 637 class mpdf_internal: public mpdf {637 class pdf_internal: public pdf { 638 638 protected : 639 639 //! Internal epdf used for sampling … … 641 641 public: 642 642 //! constructor 643 mpdf_internal() : mpdf(), iepdf() {643 pdf_internal() : pdf(), iepdf() { 644 644 // set_ep ( iepdf ); TODO! 645 645 } 646 646 647 //! Update \c iepdf so that it represents this mpdf conditioned on \c rvc = cond647 //! Update \c iepdf so that it represents this pdf conditioned on \c rvc = cond 648 648 //! This function provides convenient reimplementation in offsprings 649 649 virtual void condition ( const vec &cond ) { … … 896 896 }; 897 897 898 //!DataLink is a connection between mpdf and its superordinate (Up)898 //!DataLink is a connection between pdf and its superordinate (Up) 899 899 //! This class links 900 900 class datalink_m2m: public datalink_m2e { … … 928 928 929 929 930 //! \brief Combines RVs from a list of mpdfs to a single one.931 RV get_composite_rv ( const Array<shared_ptr< mpdf> > &mpdfs, bool checkoverlap = false );930 //! \brief Combines RVs from a list of pdfs to a single one. 931 RV get_composite_rv ( const Array<shared_ptr<pdf> > &pdfs, bool checkoverlap = false ); 932 932 933 933 /*! \brief Abstract class for discrete-time sources of data. … … 1118 1118 }; 1119 1119 //!Constructs conditional density of 1-step ahead predictor \f$ f(d_{t+1} |d_{t+h-1}, \ldots d_{t}) \f$ 1120 virtual mpdf* predictor() const {1120 virtual pdf* predictor() const { 1121 1121 bdm_error ( "Not implemented" ); 1122 1122 return NULL; … … 1229 1229 //! array of pointers to epdf 1230 1230 typedef Array<shared_ptr<epdf> > epdf_array; 1231 //! array of pointers to mpdf1232 typedef Array<shared_ptr< mpdf> > mpdf_array;1231 //! array of pointers to pdf 1232 typedef Array<shared_ptr<pdf> > pdf_array; 1233 1233 1234 1234 template<class EPDF> 1235 vec mpdf_internal<EPDF>::samplecond ( const vec &cond ) {1235 vec pdf_internal<EPDF>::samplecond ( const vec &cond ) { 1236 1236 condition ( cond ); 1237 1237 vec temp = iepdf.sample(); … … 1240 1240 1241 1241 template<class EPDF> 1242 mat mpdf_internal<EPDF>::samplecond_m ( const vec &cond, int N ) {1242 mat pdf_internal<EPDF>::samplecond_m ( const vec &cond, int N ) { 1243 1243 condition ( cond ); 1244 1244 mat temp ( dimension(), N ); … … 1253 1253 1254 1254 template<class EPDF> 1255 double mpdf_internal<EPDF>::evallogcond ( const vec &yt, const vec &cond ) {1255 double pdf_internal<EPDF>::evallogcond ( const vec &yt, const vec &cond ) { 1256 1256 double tmp; 1257 1257 condition ( cond ); … … 1261 1261 1262 1262 template<class EPDF> 1263 vec mpdf_internal<EPDF>::evallogcond_m ( const mat &Yt, const vec &cond ) {1263 vec pdf_internal<EPDF>::evallogcond_m ( const mat &Yt, const vec &cond ) { 1264 1264 condition ( cond ); 1265 1265 return iepdf.evallog_m ( Yt ); … … 1267 1267 1268 1268 template<class EPDF> 1269 vec mpdf_internal<EPDF>::evallogcond_m ( const Array<vec> &Yt, const vec &cond ) {1269 vec pdf_internal<EPDF>::evallogcond_m ( const Array<vec> &Yt, const vec &cond ) { 1270 1270 condition ( cond ); 1271 1271 return iepdf.evallog_m ( Yt ); -
library/bdm/base/datasources.cpp
r676 r693 123 123 124 124 void stateDS::from_setting ( const Setting &set ) { 125 IM = UI::build< mpdf> ( set, "IM", UI::compulsory );126 OM = UI::build< mpdf> ( set, "OM", UI::compulsory );125 IM = UI::build<pdf> ( set, "IM", UI::compulsory ); 126 OM = UI::build<pdf> ( set, "OM", UI::compulsory ); 127 127 128 128 dt.set_length ( OM->dimension() ); -
library/bdm/base/datasources.h
r676 r693 145 145 Still having only one density but allowing conditioning on either input or delayed values. 146 146 */ 147 class MpdfDS :public DS {147 class PdfDS :public DS { 148 148 protected: 149 149 //! internal pointer to epdf from which we samplecond 150 shared_ptr< mpdf> impdf;150 shared_ptr<pdf> ipdf; 151 151 //! internal storage of data sample 152 152 vec yt; … … 165 165 ut2rgr.filldown ( ut,rgr ); 166 166 yt2rgr.filldown ( yt,rgr ); 167 yt=i mpdf->samplecond ( rgr );167 yt=ipdf->samplecond ( rgr ); 168 168 ut2rgr.step(ut); //u is now history 169 169 } … … 177 177 /*! 178 178 \code 179 class = " MpdfDS";180 mpdf = {class="mpdf_offspring", ...}; // mpdf to simulate179 class = "PdfDS"; 180 pdf = {class="pdf_offspring", ...}; // pdf to simulate 181 181 --- optional --- 182 182 init_rv = {class="RV",names=...}; // define what rv to initialize - typically delayed values! … … 187 187 */ 188 188 void from_setting ( const Setting &set ) { 189 i mpdf=UI::build<mpdf> ( set,"mpdf",UI::compulsory );189 ipdf=UI::build<pdf> ( set,"pdf",UI::compulsory ); 190 190 191 Yrv = i mpdf->_rv();191 Yrv = ipdf->_rv(); 192 192 // get unique rvs form rvc 193 RV rgrv0=i mpdf->_rvc().remove_time();193 RV rgrv0=ipdf->_rvc().remove_time(); 194 194 // input is what in not in Yrv 195 195 Urv=rgrv0.subt(Yrv); 196 196 set_drv(Yrv, Urv); 197 197 // connect input and output to rvc 198 ut2rgr.set_connection(i mpdf->_rvc(), Urv);199 yt2rgr.set_connection(i mpdf->_rvc(), Yrv);198 ut2rgr.set_connection(ipdf->_rvc(), Urv); 199 yt2rgr.set_connection(ipdf->_rvc(), Yrv); 200 200 201 201 //set history - if given … … 212 212 } 213 213 214 yt = zeros ( i mpdf->dimension() );215 rgr = zeros ( i mpdf->dimensionc() );214 yt = zeros ( ipdf->dimension() ); 215 rgr = zeros ( ipdf->dimensionc() ); 216 216 ut = zeros(Urv._dsize()); 217 217 … … 225 225 ut2rgr.filldown ( ut,rgr ); 226 226 yt2rgr.filldown ( yt,rgr ); 227 yt=i mpdf->samplecond ( rgr );228 } 229 }; 230 UIREGISTER ( MpdfDS );227 yt=ipdf->samplecond ( rgr ); 228 } 229 }; 230 UIREGISTER ( PdfDS ); 231 231 232 232 /*! Pseudovirtual class for reading data from files … … 307 307 private: 308 308 //!conditional pdf of the state evolution \f$ f(x_t|x_{t-1}) \f$ 309 shared_ptr< mpdf> IM;309 shared_ptr<pdf> IM; 310 310 311 311 //!conditional pdf of the observations \f$ f(d_t|x_t) \f$ 312 shared_ptr< mpdf> OM;312 shared_ptr<pdf> OM; 313 313 314 314 protected: … … 331 331 } 332 332 //! convenience constructor 333 stateDS ( const shared_ptr< mpdf> &IM0, const shared_ptr<mpdf> &OM0, int usize ) : IM ( IM0 ), OM ( OM0 ),333 stateDS ( const shared_ptr<pdf> &IM0, const shared_ptr<pdf> &OM0, int usize ) : IM ( IM0 ), OM ( OM0 ), 334 334 dt ( OM0->dimension() ), xt ( IM0->dimension() ), 335 335 ut ( usize ), L_xt ( 0 ) { } … … 360 360 type = "stateDS"; 361 361 //Internal model 362 IM = { type = " mpdf"; //<-- valid offspring! e.g. "mlnorm"362 IM = { type = "pdf"; //<-- valid offspring! e.g. "mlnorm" 363 363 rv = { //description of x_t 364 364 names=["name1",...]; … … 373 373 }; 374 374 //Observation model 375 OM = { type = " mpdf-offspring";375 OM = { type = "pdf-offspring"; 376 376 rv = {}; //description of d_t 377 377 rvu = {type="internal", path="system.IM.rvu"}; //description of u_t -
library/bdm/estim/particles.h
r686 r693 36 36 Array<vec> &_samples; 37 37 //! Parameter evolution model 38 shared_ptr< mpdf> par;38 shared_ptr<pdf> par; 39 39 //! Observation model 40 shared_ptr< mpdf> obs;40 shared_ptr<pdf> obs; 41 41 //! internal structure storing loglikelihood of predictions 42 42 vec lls; … … 63 63 resmethod = rm; 64 64 }; 65 void set_model ( shared_ptr< mpdf> par0, shared_ptr<mpdf> obs0) {65 void set_model ( shared_ptr<pdf> par0, shared_ptr<pdf> obs0) { 66 66 par = par0; 67 67 obs = obs0; … … 105 105 /*! configuration structure for basic PF 106 106 \code 107 parameter_pdf = mpdf_class; // parameter evolution pdf108 observation_pdf = mpdf_class; // observation pdf107 parameter_pdf = pdf_class; // parameter evolution pdf 108 observation_pdf = pdf_class; // observation pdf 109 109 prior = epdf_class; // prior probability density 110 110 --- optional --- … … 117 117 void from_setting(const Setting &set){ 118 118 BM::from_setting(set); 119 par = UI::build< mpdf>(set,"parameter_pdf",UI::compulsory);120 obs = UI::build< mpdf>(set,"observation_pdf",UI::compulsory);119 par = UI::build<pdf>(set,"parameter_pdf",UI::compulsory); 120 obs = UI::build<pdf>(set,"observation_pdf",UI::compulsory); 121 121 122 122 prior_from_set(set); … … 196 196 197 197 A composition of particle filter with exact (or almost exact) bayesian models (BMs). 198 The Bayesian models provide marginalized predictive density. Internaly this is achieved by virtual class MPF mpdf.198 The Bayesian models provide marginalized predictive density. Internaly this is achieved by virtual class MPFpdf. 199 199 */ 200 200 … … 206 206 Array<BM*> BMs; 207 207 208 //! internal class for MPDFproviding composition of eEmp with external components208 //! internal class for pdf providing composition of eEmp with external components 209 209 210 210 class mpfepdf : public epdf { … … 306 306 MPF () : jest (pf,BMs) {}; 307 307 //! set all parameters at once 308 void set_parameters ( shared_ptr< mpdf> par0, shared_ptr<mpdf> obs0, int n0, RESAMPLING_METHOD rm = SYSTEMATIC ) {308 void set_parameters ( shared_ptr<pdf> par0, shared_ptr<pdf> obs0, int n0, RESAMPLING_METHOD rm = SYSTEMATIC ) { 309 309 pf->set_model ( par0, obs0); 310 310 pf->set_parameters(n0, rm ); … … 341 341 \code 342 342 BM = BM_class; // Bayesian filtr for analytical part of the model 343 parameter_pdf = mpdf_class; // transitional pdf for non-parametric part of the model343 parameter_pdf = pdf_class; // transitional pdf for non-parametric part of the model 344 344 prior = epdf_class; // prior probability density 345 345 --- optional --- … … 350 350 */ 351 351 void from_setting(const Setting &set){ 352 shared_ptr< mpdf> par = UI::build<mpdf>(set,"parameter_pdf",UI::compulsory);353 shared_ptr< mpdf> obs= new mpdf(); // not used!!352 shared_ptr<pdf> par = UI::build<pdf>(set,"parameter_pdf",UI::compulsory); 353 shared_ptr<pdf> obs= new pdf(); // not used!! 354 354 355 355 pf = new PF; -
library/bdm/stat/emix.cpp
r675 r693 54 54 } 55 55 56 shared_ptr< mpdf> emix::condition ( const RV &rv ) const {56 shared_ptr<pdf> emix::condition ( const RV &rv ) const { 57 57 bdm_assert ( isnamed(), "rvs are not assigned" ); 58 58 mratio *tmp = new mratio ( this, rv ); 59 return shared_ptr< mpdf>(tmp);59 return shared_ptr<pdf>(tmp); 60 60 } 61 61 … … 203 203 }; 204 204 205 void mprod::set_elements (const Array<shared_ptr< mpdf> > &mFacs ) {206 mpdfs = mFacs;205 void mprod::set_elements (const Array<shared_ptr<pdf> > &mFacs ) { 206 pdfs = mFacs; 207 207 dls.set_size ( mFacs.length() ); 208 208 209 rv = get_composite_rv ( mpdfs, true );209 rv = get_composite_rv ( pdfs, true ); 210 210 dim = rv._dsize(); 211 211 212 for ( int i = 0; i < mpdfs.length(); i++ ) {213 RV rvx = mpdfs ( i )->_rvc().subt ( rv );212 for ( int i = 0; i < pdfs.length(); i++ ) { 213 RV rvx = pdfs ( i )->_rvc().subt ( rv ); 214 214 rvc.add ( rvx ); // add rv to common rvc 215 215 } 216 216 dimc=rvc._dsize(); 217 217 218 // rv and rvc established = > we can link them with mpdfs219 for ( int i = 0; i < mpdfs.length(); i++ ) {218 // rv and rvc established = > we can link them with pdfs 219 for ( int i = 0; i < pdfs.length(); i++ ) { 220 220 dls ( i ) = new datalink_m2m; 221 dls ( i )->set_connection ( mpdfs ( i )->_rv(), mpdfs ( i )->_rvc(), _rv(), _rvc() );221 dls ( i )->set_connection ( pdfs ( i )->_rv(), pdfs ( i )->_rvc(), _rv(), _rvc() ); 222 222 } 223 223 } … … 239 239 240 240 } 241 // mprod::mprod ( Array< mpdf*> mFacs, bool overlap) : mpdf ( RV(), RV() ), n ( mFacs.length() ), epdfs ( n ), mpdfs ( mFacs ), rvinds ( n ), rvcinrv ( n ), irvcs_rvc ( n ) {241 // mprod::mprod ( Array<pdf*> mFacs, bool overlap) : pdf ( RV(), RV() ), n ( mFacs.length() ), epdfs ( n ), pdfs ( mFacs ), rvinds ( n ), rvcinrv ( n ), irvcs_rvc ( n ) { 242 242 // int i; 243 243 // bool rvaddok; 244 244 // // Create rv 245 245 // for ( i = 0;i < n;i++ ) { 246 // rvaddok=rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs.247 // // If rvaddok==false, mpdfs overlap => assert error.248 // epdfs ( i ) = & ( mpdfs ( i )->posterior() ); // add pointer to epdf246 // rvaddok=rv.add ( pdfs ( i )->_rv() ); //add rv to common rvs. 247 // // If rvaddok==false, pdfs overlap => assert error. 248 // epdfs ( i ) = & ( pdfs ( i )->posterior() ); // add pointer to epdf 249 249 // }; 250 250 // // Create rvc 251 251 // for ( i = 0;i < n;i++ ) { 252 // rvc.add ( mpdfs ( i )->_rvc().subt ( rv ) ); //add rv to common rvs.252 // rvc.add ( pdfs ( i )->_rvc().subt ( rv ) ); //add rv to common rvs. 253 253 // }; 254 254 // 255 255 // // independent = true; 256 // //test rvc of mpdfs and fill rvinds256 // //test rvc of pdfs and fill rvinds 257 257 // for ( i = 0;i < n;i++ ) { 258 258 // // find ith rv in common rv 259 // rvsinrv ( i ) = mpdfs ( i )->_rv().dataind ( rv );259 // rvsinrv ( i ) = pdfs ( i )->_rv().dataind ( rv ); 260 260 // // find ith rvc in common rv 261 // rvcinrv ( i ) = mpdfs ( i )->_rvc().dataind ( rv );261 // rvcinrv ( i ) = pdfs ( i )->_rvc().dataind ( rv ); 262 262 // // find ith rvc in common rv 263 // irvcs_rvc ( i ) = mpdfs ( i )->_rvc().dataind ( rvc );263 // irvcs_rvc ( i ) = pdfs ( i )->_rvc().dataind ( rvc ); 264 264 // // 265 265 // /* if ( rvcinrv ( i ).length() >0 ) {independent = false;} -
library/bdm/stat/emix.h
r675 r693 35 35 At present the only supported operation is evallogcond(). 36 36 */ 37 class mratio: public mpdf {37 class mratio: public pdf { 38 38 protected: 39 //! Nominator in the form of mpdf39 //! Nominator in the form of pdf 40 40 const epdf* nom; 41 41 … … 50 50 //!Default constructor. By default, the given epdf is not copied! 51 51 //! It is assumed that this function will be used only temporarily. 52 mratio ( const epdf* nom0, const RV &rv, bool copy = false ) : mpdf ( ), dl ( ) {52 mratio ( const epdf* nom0, const RV &rv, bool copy = false ) : pdf ( ), dl ( ) { 53 53 // adjust rv and rvc 54 54 … … 178 178 //! Update already existing marginal density \c target 179 179 void marginal ( const RV &rv, emix &target ) const; 180 shared_ptr< mpdf> condition ( const RV &rv ) const;180 shared_ptr<pdf> condition ( const RV &rv ) const; 181 181 182 182 //Access methods … … 283 283 Note that 284 284 */ 285 class mprod: public mpdf {285 class mprod: public pdf { 286 286 private: 287 Array<shared_ptr< mpdf> > mpdfs;288 289 //! Data link for each mpdfs287 Array<shared_ptr<pdf> > pdfs; 288 289 //! Data link for each pdfs 290 290 Array<shared_ptr<datalink_m2m> > dls; 291 291 … … 300 300 /*!\brief Constructor from list of mFacs 301 301 */ 302 mprod ( const Array<shared_ptr< mpdf> > &mFacs ) {302 mprod ( const Array<shared_ptr<pdf> > &mFacs ) { 303 303 set_elements ( mFacs ); 304 304 } 305 //! Set internal \c mpdfs from given values306 void set_elements (const Array<shared_ptr< mpdf> > &mFacs );305 //! Set internal \c pdfs from given values 306 void set_elements (const Array<shared_ptr<pdf> > &mFacs ); 307 307 308 308 double evallogcond ( const vec &val, const vec &cond ) { 309 309 int i; 310 310 double res = 0.0; 311 for ( i = mpdfs.length() - 1; i >= 0; i-- ) {312 /* if ( mpdfs(i)->_rvc().count() >0) {313 mpdfs ( i )->condition ( dls ( i )->get_cond ( val,cond ) );311 for ( i = pdfs.length() - 1; i >= 0; i-- ) { 312 /* if ( pdfs(i)->_rvc().count() >0) { 313 pdfs ( i )->condition ( dls ( i )->get_cond ( val,cond ) ); 314 314 } 315 315 // add logarithms 316 316 res += epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) );*/ 317 res += mpdfs ( i )->evallogcond (317 res += pdfs ( i )->evallogcond ( 318 318 dls ( i )->pushdown ( val ), 319 319 dls ( i )->get_cond ( val, cond ) … … 344 344 vec smpi; 345 345 // Hard assumption here!!! We are going backwards, to assure that samples that are needed from smp are already generated! 346 for ( int i = ( mpdfs.length() - 1 ); i >= 0; i-- ) {347 // generate contribution of this mpdf348 smpi = mpdfs(i)->samplecond(dls ( i )->get_cond ( smp , cond ));346 for ( int i = ( pdfs.length() - 1 ); i >= 0; i-- ) { 347 // generate contribution of this pdf 348 smpi = pdfs(i)->samplecond(dls ( i )->get_cond ( smp , cond )); 349 349 // copy contribution of this pdf into smp 350 350 dls ( i )->pushup ( smp, smpi ); … … 356 356 //! \code 357 357 //! { class='mprod'; 358 //! mpdfs = (..., ...); // list of mpdfs in the order of chain rule358 //! pdfs = (..., ...); // list of pdfs in the order of chain rule 359 359 //! } 360 360 //! \endcode 361 361 //!@} 362 362 void from_setting ( const Setting &set ) { 363 Array<shared_ptr< mpdf> > atmp; //temporary Array364 UI::get ( atmp, set, " mpdfs", UI::compulsory );363 Array<shared_ptr<pdf> > atmp; //temporary Array 364 UI::get ( atmp, set, "pdfs", UI::compulsory ); 365 365 set_elements ( atmp ); 366 366 } … … 460 460 461 461 462 /*! \brief Mixture of mpdfs with constant weights, all mpdfs are of equal RV and RVC462 /*! \brief Mixture of pdfs with constant weights, all pdfs are of equal RV and RVC 463 463 464 464 */ 465 class mmix : public mpdf {465 class mmix : public pdf { 466 466 protected: 467 //! Component ( mpdfs)468 Array<shared_ptr< mpdf> > Coms;467 //! Component (pdfs) 468 Array<shared_ptr<pdf> > Coms; 469 469 //!weights of the components 470 470 vec w; … … 474 474 475 475 //! Set weights \c w and components \c R 476 void set_parameters ( const vec &w0, const Array<shared_ptr< mpdf> > &Coms0 ) {476 void set_parameters ( const vec &w0, const Array<shared_ptr<pdf> > &Coms0 ) { 477 477 //!\todo check if all components are OK 478 478 Coms = Coms0; -
library/bdm/stat/exp_family.h
r679 r693 163 163 vec variance() const {return diag (R.to_mat());} 164 164 // mlnorm<sq_T>* condition ( const RV &rvn ) const ; <=========== fails to cmpile. Why? 165 shared_ptr< mpdf> condition ( const RV &rvn ) const;165 shared_ptr<pdf> condition ( const RV &rvn ) const; 166 166 167 167 // target not typed to mlnorm<sq_T, enorm<sq_T> > & … … 169 169 // haven't finished defining enorm yet), but the type 170 170 // is required 171 void condition ( const RV &rvn, mpdf &target ) const;171 void condition ( const RV &rvn, pdf &target ) const; 172 172 173 173 shared_ptr<epdf> marginal (const RV &rvn ) const; … … 367 367 */ 368 368 369 class mDirich: public mpdf_internal<eDirich> {369 class mDirich: public pdf_internal<eDirich> { 370 370 protected: 371 371 //! constant \f$ k \f$ of the random walk … … 376 376 vec betac; 377 377 public: 378 mDirich(): mpdf_internal<eDirich>(), _beta(iepdf._beta()){};378 mDirich(): pdf_internal<eDirich>(), _beta(iepdf._beta()){}; 379 379 void condition (const vec &val) {_beta = val/k+betac; }; 380 380 /*! Create Dirichlet random walk … … 391 391 */ 392 392 void from_setting (const Setting &set) { 393 mpdf::from_setting (set); // reads rv and rvc393 pdf::from_setting (set); // reads rv and rvc 394 394 if (_rv()._dsize()>0){ 395 395 rvc = _rv().copy_t(-1); … … 408 408 } 409 409 void validate() { 410 mpdf_internal<eDirich>::validate();410 pdf_internal<eDirich>::validate(); 411 411 bdm_assert(_beta.length()==betac.length(),"beta0 and betac are not compatible"); 412 412 if (_rv()._dsize()>0){ … … 644 644 645 645 //! Uniform density with conditional mean value 646 class mguni : public mpdf_internal<euni>{646 class mguni : public pdf_internal<euni>{ 647 647 //! function of the mean value 648 648 shared_ptr<fnc> mean; … … 656 656 //! load from 657 657 void from_setting(const Setting &set){ 658 mpdf::from_setting(set); //reads rv and rvc658 pdf::from_setting(set); //reads rv and rvc 659 659 UI::get(delta,set,"delta",UI::compulsory); 660 660 mean = UI::build<fnc>(set,"mean",UI::compulsory); … … 672 672 */ 673 673 template < class sq_T, template <typename> class TEpdf = enorm > 674 class mlnorm : public mpdf_internal< TEpdf<sq_T> >674 class mlnorm : public pdf_internal< TEpdf<sq_T> > 675 675 { 676 676 protected: … … 683 683 //! \name Constructors 684 684 //!@{ 685 mlnorm() : mpdf_internal< TEpdf<sq_T> >() {};686 mlnorm (const mat &A, const vec &mu0, const sq_T &R) : mpdf_internal< TEpdf<sq_T> >() {685 mlnorm() : pdf_internal< TEpdf<sq_T> >() {}; 686 mlnorm (const mat &A, const vec &mu0, const sq_T &R) : pdf_internal< TEpdf<sq_T> >() { 687 687 set_parameters (A, mu0, R); 688 688 } … … 724 724 */ 725 725 void from_setting (const Setting &set) { 726 mpdf::from_setting (set);726 pdf::from_setting (set); 727 727 728 728 UI::get (A, set, "A", UI::compulsory); … … 734 734 }; 735 735 void validate() { 736 mpdf_internal<TEpdf<sq_T> >::validate();736 pdf_internal<TEpdf<sq_T> >::validate(); 737 737 bdm_assert (A.rows() == mu_const.length(), "mlnorm: A vs. mu mismatch"); 738 738 bdm_assert (A.rows() == _R().rows(), "mlnorm: A vs. R mismatch"); … … 747 747 SHAREDPTR2 ( mlnorm, chmat ); 748 748 749 //! Mpdf with general function for mean value749 //! pdf with general function for mean value 750 750 template<class sq_T> 751 class mgnorm : public mpdf_internal< enorm< sq_T > >751 class mgnorm : public pdf_internal< enorm< sq_T > > 752 752 { 753 753 private: … … 757 757 public: 758 758 //!default constructor 759 mgnorm() : mpdf_internal<enorm<sq_T> >() { }759 mgnorm() : pdf_internal<enorm<sq_T> >() { } 760 760 //!set mean function 761 761 inline void set_parameters (const shared_ptr<fnc> &g0, const sq_T &R0); … … 782 782 783 783 void from_setting (const Setting &set) { 784 mpdf::from_setting(set);784 pdf::from_setting(set); 785 785 shared_ptr<fnc> g = UI::build<fnc> (set, "g", UI::compulsory); 786 786 … … 863 863 The standard deviation of the walk is then: \f$\mu/\sqrt(k)\f$. 864 864 */ 865 class mgamma : public mpdf_internal<egamma>865 class mgamma : public pdf_internal<egamma> 866 866 { 867 867 protected: … … 875 875 public: 876 876 //! Constructor 877 mgamma() : mpdf_internal<egamma>(), k (0),877 mgamma() : pdf_internal<egamma>(), k (0), 878 878 _beta (iepdf._beta()) { 879 879 } … … 895 895 */ 896 896 void from_setting (const Setting &set) { 897 mpdf::from_setting (set); // reads rv and rvc897 pdf::from_setting (set); // reads rv and rvc 898 898 vec betatmp; // ugly but necessary 899 899 UI::get (betatmp, set, "beta", UI::compulsory); … … 903 903 } 904 904 void validate() { 905 mpdf_internal<egamma>::validate();905 pdf_internal<egamma>::validate(); 906 906 907 907 dim = _beta.length(); … … 921 921 The standard deviation of the walk is then: \f$ \mu/\sqrt(k)\f$. 922 922 */ 923 class migamma : public mpdf_internal<eigamma>923 class migamma : public pdf_internal<eigamma> 924 924 { 925 925 protected: … … 936 936 //! \name Constructors 937 937 //!@{ 938 migamma() : mpdf_internal<eigamma>(),938 migamma() : pdf_internal<eigamma>(), 939 939 k (0), 940 940 _alpha (iepdf._alpha()), … … 942 942 } 943 943 944 migamma (const migamma &m) : mpdf_internal<eigamma>(),944 migamma (const migamma &m) : pdf_internal<eigamma>(), 945 945 k (0), 946 946 _alpha (iepdf._alpha()), … … 1074 1074 1075 1075 */ 1076 class mlognorm : public mpdf_internal<elognorm>1076 class mlognorm : public pdf_internal<elognorm> 1077 1077 { 1078 1078 protected: … … 1084 1084 public: 1085 1085 //! Constructor 1086 mlognorm() : mpdf_internal<elognorm>(),1086 mlognorm() : pdf_internal<elognorm>(), 1087 1087 sig2 (0), 1088 1088 mu (iepdf._mu()) { … … 1221 1221 1222 1222 //! Random Walk on inverse Wishart 1223 class rwiWishartCh : public mpdf_internal<eiWishartCh>1223 class rwiWishartCh : public pdf_internal<eiWishartCh> 1224 1224 { 1225 1225 protected: … … 1474 1474 1475 1475 template<class sq_T> 1476 shared_ptr< mpdf> enorm<sq_T>::condition ( const RV &rvn ) const1476 shared_ptr<pdf> enorm<sq_T>::condition ( const RV &rvn ) const 1477 1477 { 1478 1478 mlnorm<sq_T> *tmp = new mlnorm<sq_T> (); 1479 shared_ptr< mpdf> narrow(tmp);1479 shared_ptr<pdf> narrow(tmp); 1480 1480 condition ( rvn, *tmp ); 1481 1481 return narrow; … … 1483 1483 1484 1484 template<class sq_T> 1485 void enorm<sq_T>::condition ( const RV &rvn, mpdf &target ) const1485 void enorm<sq_T>::condition ( const RV &rvn, pdf &target ) const 1486 1486 { 1487 1487 typedef mlnorm<sq_T> TMlnorm; -
library/bdm/stat/merger.cpp
r682 r693 5 5 namespace bdm { 6 6 7 merger_base::merger_base ( const Array<shared_ptr< mpdf> > &S ):7 merger_base::merger_base ( const Array<shared_ptr<pdf> > &S ): 8 8 Npoints(0), DBG(false), dbg_file(0) { 9 9 set_sources ( S ); … … 134 134 135 135 136 sprintf ( dbg_str, " Mpdf%d", niter );136 sprintf ( dbg_str, "pdf%d", niter ); 137 137 for ( int i = 0; i < Npoints; i++ ) { 138 138 Mix_pdf ( i ) = Mix.logpred ( Smp_ex.get_col ( i ) ); … … 145 145 } 146 146 //Importace weighting 147 for ( int i = 0; i < mpdfs.length(); i++ ) {147 for ( int i = 0; i < pdfs.length(); i++ ) { 148 148 lw_src = 0.0; 149 149 //======== Same RVs =========== 150 150 //Split according to dependency in rvs 151 if ( mpdfs ( i )->dimension() == dim ) {151 if ( pdfs ( i )->dimension() == dim ) { 152 152 // no need for conditioning or marginalization 153 lw_src = mpdfs ( i )->evallogcond_m ( Smp , vec(0));153 lw_src = pdfs ( i )->evallogcond_m ( Smp , vec(0)); 154 154 } else { 155 155 // compute likelihood of marginal on the conditional variable 156 if ( mpdfs ( i )->dimensionc() > 0 ) {156 if ( pdfs ( i )->dimensionc() > 0 ) { 157 157 // Make marginal on rvc_i 158 shared_ptr<epdf> tmp_marg = Mpred->marginal ( mpdfs ( i )->_rvc() );158 shared_ptr<epdf> tmp_marg = Mpred->marginal ( pdfs ( i )->_rvc() ); 159 159 //compute vector of lw_src 160 160 for ( int k = 0; k < Npoints; k++ ) { 161 // Here val of tmp_marg = cond of mpdfs(i) ==> calling dls->get_cond161 // Here val of tmp_marg = cond of pdfs(i) ==> calling dls->get_cond 162 162 lw_src ( k ) += tmp_marg->evallog ( dls ( i )->get_cond ( Smp ( k ) ) ); 163 163 } … … 168 168 } 169 169 // Compute likelihood of the missing variable 170 if ( dim > ( mpdfs ( i )->dimension() + mpdfs ( i )->dimensionc() ) ) {170 if ( dim > ( pdfs ( i )->dimension() + pdfs ( i )->dimensionc() ) ) { 171 171 /////////////// 172 // There are variales unknown to mpdfs(i) : rvzs173 shared_ptr< mpdf> tmp_cond = Mpred->condition ( rvzs ( i ) );172 // There are variales unknown to pdfs(i) : rvzs 173 shared_ptr<pdf> tmp_cond = Mpred->condition ( rvzs ( i ) ); 174 174 // Compute likelihood 175 175 vec lw_dbg = lw_src; … … 187 187 // Compute likelihood of the partial source 188 188 for ( int k = 0; k < Npoints; k++ ) { 189 lw_src ( k ) += mpdfs ( i )->evallogcond ( dls ( i )->pushdown ( Smp ( k ) ),189 lw_src ( k ) += pdfs ( i )->evallogcond ( dls ( i )->pushdown ( Smp ( k ) ), 190 190 dls ( i )->get_cond ( Smp ( k ) )); 191 191 } -
library/bdm/stat/merger.h
r679 r693 46 46 protected: 47 47 //! Elements of composition 48 Array<shared_ptr< mpdf> > mpdfs;49 50 //! Data link for each mpdf in mpdfs48 Array<shared_ptr<pdf> > pdfs; 49 50 //! Data link for each pdf in pdfs 51 51 Array<datalink_m2e*> dls; 52 52 53 //! Array of rvs that are not modelled by mpdfs at all, \f$ z_i \f$53 //! Array of rvs that are not modelled by pdfs at all, \f$ z_i \f$ 54 54 Array<RV> rvzs; 55 55 … … 90 90 91 91 //!Constructor from sources 92 merger_base ( const Array<shared_ptr< mpdf> > &S );92 merger_base ( const Array<shared_ptr<pdf> > &S ); 93 93 94 94 //! Function setting the main internal structures 95 void set_sources ( const Array<shared_ptr< mpdf> > &Sources ) {96 mpdfs = Sources;97 Nsources = mpdfs.length();95 void set_sources ( const Array<shared_ptr<pdf> > &Sources ) { 96 pdfs = Sources; 97 Nsources = pdfs.length(); 98 98 //set sizes 99 99 dls.set_size ( Sources.length() ); … … 101 101 zdls.set_size ( Sources.length() ); 102 102 103 rv = get_composite_rv ( mpdfs, /* checkoverlap = */ false );103 rv = get_composite_rv ( pdfs, /* checkoverlap = */ false ); 104 104 105 105 RV rvc; 106 106 // Extend rv by rvc! 107 for ( int i = 0; i < mpdfs.length(); i++ ) {108 RV rvx = mpdfs ( i )->_rvc().subt ( rv );107 for ( int i = 0; i < pdfs.length(); i++ ) { 108 RV rvx = pdfs ( i )->_rvc().subt ( rv ); 109 109 rvc.add ( rvx ); // add rv to common rvc 110 110 } … … 117 117 // create links between sources and common rv 118 118 RV xytmp; 119 for ( int i = 0; i < mpdfs.length(); i++ ) {120 //Establich connection between mpdfs and merger119 for ( int i = 0; i < pdfs.length(); i++ ) { 120 //Establich connection between pdfs and merger 121 121 dls ( i ) = new datalink_m2e; 122 dls ( i )->set_connection ( mpdfs ( i )->_rv(), mpdfs ( i )->_rvc(), rv );123 124 // find out what is missing in each mpdf125 xytmp = mpdfs ( i )->_rv();126 xytmp.add ( mpdfs ( i )->_rvc() );122 dls ( i )->set_connection ( pdfs ( i )->_rv(), pdfs ( i )->_rvc(), rv ); 123 124 // find out what is missing in each pdf 125 xytmp = pdfs ( i )->_rv(); 126 xytmp.add ( pdfs ( i )->_rvc() ); 127 127 // z_i = common_rv-xy 128 128 rvzs ( i ) = rv.subt ( xytmp ); … … 185 185 //check if sources overlap: 186 186 bool OK = true; 187 for ( int i = 0; i < mpdfs.length(); i++ ) {187 for ( int i = 0; i < pdfs.length(); i++ ) { 188 188 OK &= ( rvzs ( i )._dsize() == 0 ); // z_i is empty 189 OK &= ( mpdfs ( i )->_rvc()._dsize() == 0 ); // y_i is empty189 OK &= ( pdfs ( i )->_rvc()._dsize() == 0 ); // y_i is empty 190 190 } 191 191 192 192 if ( OK ) { 193 mat lW = zeros ( mpdfs.length(), eSmp._w().length() );193 mat lW = zeros ( pdfs.length(), eSmp._w().length() ); 194 194 195 195 vec emptyvec ( 0 ); 196 for ( int i = 0; i < mpdfs.length(); i++ ) {196 for ( int i = 0; i < pdfs.length(); i++ ) { 197 197 for ( int j = 0; j < eSmp._w().length(); j++ ) { 198 lW ( i, j ) = mpdfs ( i )->evallogcond ( eSmp._samples() ( j ), emptyvec );198 lW ( i, j ) = pdfs ( i )->evallogcond ( eSmp._samples() ( j ), emptyvec ); 199 199 } 200 200 } … … 313 313 merger_mix ():Ncoms(0), effss_coef(0), stop_niter(0) { } 314 314 315 merger_mix ( const Array<shared_ptr< mpdf> > &S ):315 merger_mix ( const Array<shared_ptr<pdf> > &S ): 316 316 Ncoms(0), effss_coef(0), stop_niter(0) { 317 317 set_sources ( S ); … … 319 319 320 320 //! Set sources and prepare all internal structures 321 void set_sources ( const Array<shared_ptr< mpdf> > &S ) {321 void set_sources ( const Array<shared_ptr<pdf> > &S ) { 322 322 merger_base::set_sources ( S ); 323 323 Nsources = S.length(); -
library/doc/tutorial/01userguide.dox
r664 r693 162 162 - bdm::CsvFileDS 163 163 - bdm::ITppFileDS 164 - bdm:: MpdfDS164 - bdm::PdfDS 165 165 - bdm::stateDS 166 166 … … 243 243 fu.R = 0.2; 244 244 245 DS.class = ' MpdfDS';246 DS. mpdf.class = 'mprod';247 DS. mpdf.mpdfs = {fy, epdf2mpdf(fu)};245 DS.class = 'pdfDS'; 246 DS.pdf.class = 'mprod'; 247 DS.pdf.pdfs = {fy, epdf2mpdf(fu)}; 248 248 \endcode 249 249 … … 252 252 - naming convention 'mlnorm\<ldmat\>' relates to the concept of templates in C++. For those unfamiliar with this concept, it is basicaly a way how to share code for different flavours of the same object. Note that mlnorm exist in three versions: mlnorm\<ldmat\>, mlnorm<chmat>, mlnorm<fsqmat>. Those classes act identically the only difference is that the internal data are stored either in LD decomposition, choleski decomposition or full matrices, respectively. 253 253 - the same concept is used for enorm, where enorm<chmat> and enorm<fsqmat> are also possible. In this particular use, these objects are equivalent. In specific situation, e.g. Kalman filter implemented on Choleski decomposition (bdm::KalmanCh), only enorm<chmat> is approprate. 254 - class 'mprod' represents the chain rule of probability. Attribute \c mpdfs of its configuration structure is a list of conditional densities. Conditional density \f$ f(a|b)\f$ is represented by class \c mpdf and its offsprings. Class \c RV is used to describe both variables before conditioning (field \c rv ) and after conditioning sign (field \c rvc).255 - due to simplicity of implementation, mprod accept only conditional densities in the field \c mpdfs. Hence, the pdf \f$ f(u_t)\f$ must be converted to conditional density with empty conditioning, \f$ f(u_t| \{\})\f$. This is achieved by calling function epdf2mpdf which is only a trivial wrapper creating class bdm::mepdf.254 - class 'mprod' represents the chain rule of probability. Attribute \c pdfs of its configuration structure is a list of conditional densities. Conditional density \f$ f(a|b)\f$ is represented by class \c pdf and its offsprings. Class \c RV is used to describe both variables before conditioning (field \c rv ) and after conditioning sign (field \c rvc). 255 - due to simplicity of implementation, mprod accept only conditional densities in the field \c pdfs. Hence, the pdf \f$ f(u_t)\f$ must be converted to conditional density with empty conditioning, \f$ f(u_t| \{\})\f$. This is achieved by calling function epdf2mpdf which is only a trivial wrapper creating class bdm::mepdf. 256 256 257 257 … … 260 260 \subsection ug_ini Initializing simulation 261 261 262 When zeros are not appropriate initial conditions, the correct conditions can be set using additional commands (see bdm:: MpdfDS.from_setting() ):262 When zeros are not appropriate initial conditions, the correct conditions can be set using additional commands (see bdm::pdfDS.from_setting() ): 263 263 \code 264 264 DS.init_rv = RV({'y','y','y'}, [1,1,1], [-1,-2,-3]); … … 281 281 Data=[M.y; M.u]; 282 282 drv = RVjoin({y,u}); 283 save mpdfds_results Data drv283 save pdfds_results Data drv 284 284 \endcode 285 285 Such data can be later provided e.g. by MemDS -
library/doc/tutorial/02userguide2.dox
r659 r693 106 106 \section ug2_bm_composition Composition of estimators 107 107 108 Similarly to mpdfs which could be composed via \c mprod, the Bayesian models can be composed. However, justification of this step is less clear than in the case of epdfs.108 Similarly to pdfs which could be composed via \c mprod, the Bayesian models can be composed. However, justification of this step is less clear than in the case of epdfs. 109 109 110 110 One possible theoretical base of composition is the Marginalized particle filter, which splits the prior and the posterior in two parts: -
library/doc/tutorial/unit_testing.dox
r613 r693 118 118 119 119 Testsuite has explicit support for testing classes derived from 120 bdm::epdf and bdm:: mpdf: bdm::epdf_harness and121 bdm:: mpdf_harness. These classes run a list of tests on objects120 bdm::epdf and bdm::pdf: bdm::epdf_harness and 121 bdm::pdf_harness. These classes run a list of tests on objects 122 122 created from the specified configuration file (normally called 123 123 <classname>.cfg) and check them against expected values also -
library/system/SetBdmEnv.cmake
r662 r693 27 27 ADD_DEFINITIONS(/wd4290) 28 28 ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) 29 ADD_DEFINITIONS(-DLIBCONFIG_STATIC -DLIBCONFIGXX_STATIC) 29 30 ENDIF(WIN32) 30 31 IF(APPLE) -
library/tests/CMakeLists.txt
r691 r693 8 8 9 9 SET(testutil_src epdf_harness.cpp epdf_harness.h mat_checks.cpp mat_checks.h 10 mpdf_harness.cpp mpdf_harness.h square_mat_point.cpp square_mat_point.h test_util.cpp test_util.h)10 pdf_harness.cpp pdf_harness.h square_mat_point.cpp square_mat_point.h test_util.cpp test_util.h) 11 11 12 12 add_library(testutil ${testutil_src}) … … 41 41 # using UnitTest++ 42 42 43 SET(unit_test_configurations mepdf.cfg egiw.cfg mlnorm.cfg edirich.cfg mprod.cfg generator.cfg epdfds.cfg mpdfds.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 mepdf.cfg 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 46 mpdf_test.cpp randun_test.cpp rectangular_support_test.cpp rv_test.cpp shared_ptr_test.cpp square_mat_test.cpp testsuite.cpp user_info_test.cpp ${unit_test_configurations} )46 pdf_test.cpp randun_test.cpp rectangular_support_test.cpp rv_test.cpp shared_ptr_test.cpp square_mat_test.cpp testsuite.cpp user_info_test.cpp ${unit_test_configurations} ) 47 47 48 48 set_source_files_properties(${unit_test_configurations} PROPERTIES HEADER_FILE_ONLY TRUE) -
library/tests/datasource_test.cpp
r689 r693 20 20 } 21 21 22 TEST ( MpdfDS_test ) {23 UIFile uif(" mpdfds.cfg");22 TEST ( PdfDS_test ) { 23 UIFile uif("pdfds.cfg"); 24 24 25 shared_ptr< MpdfDS> ds=UI::build<MpdfDS>(uif, "ds", UI::compulsory);25 shared_ptr<PdfDS> ds=UI::build<PdfDS>(uif, "ds", UI::compulsory); 26 26 27 27 vec dt = zeros(2); -
library/tests/emix_test.cpp
r689 r693 37 37 epdf_ptr Mm = M1.marginal ( y ); 38 38 epdf_ptr Am = E1->marginal ( y ); 39 mpdf_ptr Mc = M1.condition ( y );40 mpdf_ptr Ac = E1->condition ( y );39 pdf_ptr Mc = M1.condition ( y ); 40 pdf_ptr Ac = E1->condition ( y ); 41 41 42 42 mlnorm<ldmat> *wacnd = dynamic_cast<mlnorm<ldmat> *>( Ac.get() ); … … 81 81 epdf_ptr Mg = M2.marginal ( y ); 82 82 CHECK ( Mg.get() ); 83 mpdf_ptr Cn = M2.condition ( x );83 pdf_ptr Cn = M2.condition ( x ); 84 84 CHECK ( Cn.get() ); 85 85 -
library/tests/epdf_harness.cpp
r675 r693 67 67 RV crv = hepdf->_rv().subt ( *mrv ); 68 68 epdf_ptr m = hepdf->marginal ( *mrv ); 69 mpdf_ptr c = hepdf->condition ( crv );70 71 mpdf_array aa ( 2 );69 pdf_ptr c = hepdf->condition ( crv ); 70 71 pdf_array aa ( 2 ); 72 72 aa ( 0 ) = c; 73 73 aa ( 1 ) = m; -
library/tests/mepdf.cfg
r675 r693 1 1 data = ( 2 2 { 3 class = " mpdf_harness";4 mpdf = {3 class = "pdf_harness"; 4 pdf = { 5 5 class = "enorm<ldmat>"; 6 6 mu = [ 1.1, -1.0 ]; -
library/tests/merger_2d_test.cpp
r675 r693 31 31 f2->set_parameters ( "1 1", mat ( "0.5 0; 0 0.1" ) ); 32 32 33 mpdf_array A ( 2 );33 pdf_array A ( 2 ); 34 34 A ( 0 ) = f1; 35 35 A ( 1 ) = f2; -
library/tests/merger_iter_test.cpp
r675 r693 32 32 f3->set_parameters ( "2", mat ( "0.4" ) ); 33 33 34 mpdf_array A ( 3 );34 pdf_array A ( 3 ); 35 35 A ( 0 ) = f1; 36 36 A ( 1 ) = f2; -
library/tests/merger_test.cpp
r689 r693 21 21 f2->set_parameters ( "5", mat ( "10" ) ); 22 22 23 mpdf_array A ( 2 );23 pdf_array A ( 2 ); 24 24 A ( 0 ) = f1; 25 25 A ( 1 ) = f2; … … 144 144 UI::build<merger_base> ( in, "Merger", UI::compulsory ); 145 145 146 mpdf_array sources;146 pdf_array sources; 147 147 UI::get ( sources, in, "Sources", UI::compulsory ); 148 148 mb->set_sources ( sources ); … … 160 160 UIFile in ( "merger_error.cfg" ); 161 161 162 mpdf_array sources;162 pdf_array sources; 163 163 try { 164 164 UI::get ( sources, in, "Sources", UI::compulsory ); -
library/tests/mgamma.cfg
r521 r693 1 1 data = ( 2 2 { 3 class = " mpdf_harness";4 mpdf = {3 class = "pdf_harness"; 4 pdf = { 5 5 class = "mgamma"; 6 6 beta = [ 1.5, 1.7 ]; … … 24 24 }, 25 25 { 26 class = " mpdf_harness";27 mpdf = {26 class = "pdf_harness"; 27 pdf = { 28 28 class = "mgamma"; 29 29 beta = [ 1.5, 1.7 ]; -
library/tests/mlnorm.cfg
r489 r693 1 1 data = ( 2 2 { 3 class = " mpdf_harness";4 mpdf = {3 class = "pdf_harness"; 4 pdf = { 5 5 class = "mlnorm<ldmat>"; 6 6 A = ( "matrix", 2, 2, [ 1.0, 0.0, 0.0, 1.0 ] ); … … 15 15 }, 16 16 { 17 class = " mpdf_harness";18 mpdf = {17 class = "pdf_harness"; 18 pdf = { 19 19 class = "mlnorm<chmat>"; 20 20 A = ( "matrix", 2, 2, [ 1.0, 0.0, 0.0, 1.0 ] ); -
library/tests/mprod.cfg
r675 r693 1 1 data = ( 2 2 { 3 class = " mpdf_harness";4 mpdf = {3 class = "pdf_harness"; 4 pdf = { 5 5 class = "mprod"; 6 mpdfs = (6 pdfs = ( 7 7 { 8 8 class = "mgamma"; … … 37 37 }, 38 38 { 39 class = " mpdf_harness";40 mpdf = {39 class = "pdf_harness"; 40 pdf = { 41 41 class = "mprod"; 42 mpdfs = (42 pdfs = ( 43 43 { 44 44 class = "enorm<ldmat>"; -
library/tests/pdf_harness.cpp
r527 r693 1 #include " mpdf_harness.h"1 #include "pdf_harness.h" 2 2 #include "base/bdmbase.h" 3 3 #include "base/user_info.h" … … 9 9 namespace bdm { 10 10 11 void mpdf_harness::test_config ( const char *config_file_name ) {11 void pdf_harness::test_config ( const char *config_file_name ) { 12 12 RV::clear_all(); 13 13 14 14 UIFile in ( config_file_name ); 15 Array<shared_ptr< mpdf_harness> > input;15 Array<shared_ptr<pdf_harness> > input; 16 16 UI::get ( input, in, "data", UI::compulsory ); 17 17 int sz = input.size(); … … 22 22 } 23 23 24 void mpdf_harness::from_setting ( const Setting &set ) {25 h mpdf = UI::build<mpdf> ( set, "mpdf", UI::compulsory );24 void pdf_harness::from_setting ( const Setting &set ) { 25 hpdf = UI::build<pdf> ( set, "pdf", UI::compulsory ); 26 26 UI::get ( mean, set, "mean", UI::compulsory ); 27 27 UI::get ( variance, set, "variance", UI::compulsory ); 28 28 29 29 if ( !UI::get ( cond, set, "cond", UI::optional ) ) { 30 cond = zeros ( h mpdf->dimensionc() );30 cond = zeros ( hpdf->dimensionc() ); 31 31 } 32 32 … … 36 36 } 37 37 38 void mpdf_harness::test ( const char *config_name, int idx ) {38 void pdf_harness::test ( const char *config_name, int idx ) { 39 39 CurrentContext cc ( config_name, idx ); 40 40 check_mean(); … … 44 44 } 45 45 46 void mpdf_harness::check_mean() {46 void pdf_harness::check_mean() { 47 47 vec delta = make_close_tolerance ( variance, nsamples ); 48 48 … … 50 50 Array<vec> actual(CurrentContext::max_trial_count); 51 51 do { 52 mat smp = h mpdf->samplecond_m ( cond, nsamples );52 mat smp = hpdf->samplecond_m ( cond, nsamples ); 53 53 vec emu = smp * ones ( nsamples ) / nsamples; 54 54 actual( tc ) = emu; … … 67 67 } 68 68 69 void mpdf_harness::check_covariance() {69 void pdf_harness::check_covariance() { 70 70 int tc = 0; 71 71 Array<mat> actual(CurrentContext::max_trial_count); 72 72 do { 73 mat smp = h mpdf->samplecond_m ( cond, nsamples );73 mat smp = hpdf->samplecond_m ( cond, nsamples ); 74 74 vec emu = smp * ones ( nsamples ) / nsamples; 75 75 mat er = ( smp * smp.T() ) / nsamples - outer_product ( emu, emu ); -
library/tests/pdf_harness.h
r493 r693 1 1 /*! 2 2 \file 3 \brief Support for testing descendants of mpdf.3 \brief Support for testing descendants of pdf. 4 4 \author Vaclav Barta. 5 5 … … 11 11 */ 12 12 13 #ifndef MPDF_HARNESS_H14 #define MPDF_HARNESS_H13 #ifndef pdf_HARNESS_H 14 #define pdf_HARNESS_H 15 15 16 16 #include "bdmroot.h" … … 22 22 namespace bdm { 23 23 24 class mpdf_harness : public root {24 class pdf_harness : public root { 25 25 private: 26 shared_ptr< mpdf> hmpdf;26 shared_ptr<pdf> hpdf; 27 27 vec cond; 28 28 vec mean; … … 35 35 static void test_config ( const char *config_file_name ); 36 36 37 mpdf_harness() : nsamples ( 1000 ), tolerance ( 0.1 ) { }37 pdf_harness() : nsamples ( 1000 ), tolerance ( 0.1 ) { } 38 38 39 39 virtual void test ( const char *config_name, int idx ); … … 42 42 43 43 protected: 44 mpdf *get_mpdf() {45 return h mpdf.get();44 pdf *get_pdf() { 45 return hpdf.get(); 46 46 } 47 47 … … 52 52 void check_covariance(); 53 53 }; 54 UIREGISTER( mpdf_harness);54 UIREGISTER(pdf_harness); 55 55 56 56 } -
library/tests/pdf_test.cpp
r689 r693 3 3 #include "stat/emix.h" 4 4 #include "itpp_ext.h" 5 #include " mpdf_harness.h"5 #include "pdf_harness.h" 6 6 #include "mat_checks.h" 7 7 #include "UnitTest++.h" … … 9 9 using namespace bdm; 10 10 11 static void check_mean( mpdf &distrib_obj, const vec &mu0, int nsamples, const vec &mean, double tolerance);11 static void check_mean(pdf &distrib_obj, const vec &mu0, int nsamples, const vec &mean, double tolerance); 12 12 13 13 static void check_covariance(mmix &distrib_obj, const vec &mu0, int nsamples, const mat &R, double tolerance); 14 14 15 15 TEST ( mepdf_test ) { 16 mpdf_harness::test_config ( "mepdf.cfg" );16 pdf_harness::test_config ( "mepdf.cfg" ); 17 17 } 18 18 19 19 TEST ( mgamma_test ) { 20 mpdf_harness::test_config ( "mgamma.cfg" );20 pdf_harness::test_config ( "mgamma.cfg" ); 21 21 } 22 22 23 23 TEST ( mlnorm_test ) { 24 mpdf_harness::test_config ( "mlnorm.cfg" );24 pdf_harness::test_config ( "mlnorm.cfg" ); 25 25 } 26 26 27 27 TEST ( mprod_test ) { 28 mpdf_harness::test_config ( "mprod.cfg" );28 pdf_harness::test_config ( "mprod.cfg" ); 29 29 } 30 30 31 // not using mpdf_harness because mmix isn't configurable (yet?)31 // not using pdf_harness because mmix isn't configurable (yet?) 32 32 TEST ( mmix_test ) { 33 33 RV x ( "{mmixx }", "2" ); … … 46 46 47 47 mmix mMix; 48 mpdf_array mComs ( 2 );48 pdf_array mComs ( 2 ); 49 49 50 // mmix::set_parameters requires the first mpdf to be named50 // mmix::set_parameters requires the first pdf to be named 51 51 mG->set_rv(x); 52 52 mG->set_rvc(y); … … 65 65 } 66 66 67 // not using mpdf_harness because emix isn't configurable (yet?)67 // not using pdf_harness because emix isn't configurable (yet?) 68 68 TEST ( mepdf_emix_test ) { 69 69 int N = 10000; //number of samples … … 89 89 } 90 90 91 static void check_mean( mpdf &distrib_obj, const vec &mu0, int nsamples, const vec &mean, double tolerance) {91 static void check_mean(pdf &distrib_obj, const vec &mu0, int nsamples, const vec &mean, double tolerance) { 92 92 int tc = 0; 93 93 Array<vec> actual(CurrentContext::max_trial_count); -
library/tests/pdfds.cfg
r598 r693 1 1 ds={ 2 class = " MpdfDS";3 mpdf = {2 class = "PdfDS"; 3 pdf = { 4 4 class = "mlnorm<ldmat>"; 5 5 A = ( "matrix", 1, 2, [ 0.5, -0.1 ] );