Changeset 693 for library/bdm/base

Show
Ignore:
Timestamp:
11/02/09 17:27:29 (15 years ago)
Author:
mido
Message:

mpdf renamed to pdf in the whole library

Location:
library/bdm/base
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/bdmbase.cpp

    r690 r693  
    146146} 
    147147 
    148 shared_ptr<mpdf> epdf::condition ( const RV &rv ) const { 
     148shared_ptr<pdf> epdf::condition ( const RV &rv ) const { 
    149149        bdm_warning ( "Not implemented" ); 
    150         return shared_ptr<mpdf>(); 
     150        return shared_ptr<pdf>(); 
    151151} 
    152152 
     
    180180} 
    181181 
    182 mat mpdf::samplecond_m ( const vec &cond, int N ) { 
     182mat pdf::samplecond_m ( const vec &cond, int N ) { 
    183183        mat M ( dimension(), N ); 
    184184        for ( int i = 0; i < N; i++ ) { 
     
    189189} 
    190190 
    191 void mpdf::from_setting ( const Setting &set ) { 
     191void pdf::from_setting ( const Setting &set ) { 
    192192        shared_ptr<RV> r = UI::build<RV> ( set, "rv", UI::optional ); 
    193193        if ( r ) { 
     
    373373} 
    374374 
    375 RV get_composite_rv ( const Array<shared_ptr<mpdf> > &mpdfs, 
     375RV get_composite_rv ( const Array<shared_ptr<pdf> > &pdfs, 
    376376                      bool checkoverlap ) { 
    377377        RV rv; //empty rv 
    378378        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!" ); 
    383383        } 
    384384 
  • library/bdm/base/bdmbase.h

    r690 r693  
    386386 
    387387//! 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 { 
     388class pdf : public root { 
    389389protected: 
    390390        //!dimension of the condition 
     
    403403        //! @{ 
    404404 
    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 ) { } 
    408408         
    409409        //! 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);} 
    411411        //!@} 
    412412 
     
    467467        //! Load from structure with elements: 
    468468        //!  \code 
    469         //! { class = "mpdf_offspring", 
     469        //! { class = "pdf_offspring", 
    470470        //!   rv = {class="RV", names=(...),}; // RV describing meaning of random variable 
    471471        //!   rvc= {class="RV", names=(...),}; // RV describing meaning of random variable in condition 
     
    491491        //!@} 
    492492}; 
    493 SHAREDPTR ( mpdf ); 
     493SHAREDPTR ( pdf ); 
    494494 
    495495//! Probability density function with numerical statistics, e.g. posterior density. 
    496 class epdf : public mpdf { 
     496class epdf : public pdf { 
    497497 
    498498public: 
     
    509509        @{*/ 
    510510        epdf() {}; 
    511         epdf ( const epdf &e ) : mpdf(e) {}; 
     511        epdf ( const epdf &e ) : pdf(e) {}; 
    512512        void set_parameters ( int dim0 ) { 
    513513                dim = dim0; 
     
    542542 
    543543        //! 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; 
    545545 
    546546        //! Return marginal density on the given RV, the remainig rvs are intergrated out 
     
    633633SHAREDPTR ( epdf ); 
    634634 
    635 //! Mpdf with internal epdf that is modified by function \c condition 
     635//! pdf with internal epdf that is modified by function \c condition 
    636636template <class EPDF> 
    637 class mpdf_internal: public mpdf { 
     637class pdf_internal: public pdf { 
    638638protected : 
    639639        //! Internal epdf used for sampling 
     
    641641public: 
    642642        //! constructor 
    643         mpdf_internal() : mpdf(), iepdf() { 
     643        pdf_internal() : pdf(), iepdf() { 
    644644//              set_ep ( iepdf ); TODO! 
    645645        } 
    646646 
    647         //! Update \c iepdf so that it represents this mpdf conditioned on \c rvc = cond 
     647        //! Update \c iepdf so that it represents this pdf conditioned on \c rvc = cond 
    648648        //! This function provides convenient reimplementation in offsprings 
    649649        virtual void condition ( const vec &cond ) { 
     
    896896}; 
    897897 
    898 //!DataLink is a connection between mpdf and its superordinate (Up) 
     898//!DataLink is a connection between pdf and its superordinate (Up) 
    899899//! This class links 
    900900class datalink_m2m: public datalink_m2e { 
     
    928928 
    929929 
    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. 
     931RV get_composite_rv ( const Array<shared_ptr<pdf> > &pdfs, bool checkoverlap = false ); 
    932932 
    933933/*! \brief Abstract class for discrete-time sources of data. 
     
    11181118        }; 
    11191119        //!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 { 
    11211121                bdm_error ( "Not implemented" ); 
    11221122                return NULL; 
     
    12291229//! array of pointers to epdf 
    12301230typedef Array<shared_ptr<epdf> > epdf_array; 
    1231 //! array of pointers to mpdf 
    1232 typedef Array<shared_ptr<mpdf> > mpdf_array; 
     1231//! array of pointers to pdf 
     1232typedef Array<shared_ptr<pdf> > pdf_array; 
    12331233 
    12341234template<class EPDF> 
    1235 vec mpdf_internal<EPDF>::samplecond ( const vec &cond ) { 
     1235vec pdf_internal<EPDF>::samplecond ( const vec &cond ) { 
    12361236        condition ( cond ); 
    12371237        vec temp = iepdf.sample(); 
     
    12401240 
    12411241template<class EPDF> 
    1242 mat mpdf_internal<EPDF>::samplecond_m ( const vec &cond, int N ) { 
     1242mat pdf_internal<EPDF>::samplecond_m ( const vec &cond, int N ) { 
    12431243        condition ( cond ); 
    12441244        mat temp ( dimension(), N ); 
     
    12531253 
    12541254template<class EPDF> 
    1255 double mpdf_internal<EPDF>::evallogcond ( const vec &yt, const vec &cond ) { 
     1255double pdf_internal<EPDF>::evallogcond ( const vec &yt, const vec &cond ) { 
    12561256        double tmp; 
    12571257        condition ( cond ); 
     
    12611261 
    12621262template<class EPDF> 
    1263 vec mpdf_internal<EPDF>::evallogcond_m ( const mat &Yt, const vec &cond ) { 
     1263vec pdf_internal<EPDF>::evallogcond_m ( const mat &Yt, const vec &cond ) { 
    12641264        condition ( cond ); 
    12651265        return iepdf.evallog_m ( Yt ); 
     
    12671267 
    12681268template<class EPDF> 
    1269 vec mpdf_internal<EPDF>::evallogcond_m ( const Array<vec> &Yt, const vec &cond ) { 
     1269vec pdf_internal<EPDF>::evallogcond_m ( const Array<vec> &Yt, const vec &cond ) { 
    12701270        condition ( cond ); 
    12711271        return iepdf.evallog_m ( Yt ); 
  • library/bdm/base/datasources.cpp

    r676 r693  
    123123 
    124124void 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 ); 
    127127 
    128128        dt.set_length ( OM->dimension() ); 
  • library/bdm/base/datasources.h

    r676 r693  
    145145Still having only one density but allowing conditioning on either input or delayed values. 
    146146*/ 
    147 class MpdfDS :public DS { 
     147class PdfDS :public DS { 
    148148        protected: 
    149149                //! internal pointer to epdf from which we samplecond 
    150                 shared_ptr<mpdf> impdf; 
     150                shared_ptr<pdf> ipdf; 
    151151                //! internal storage of data sample 
    152152                vec yt; 
     
    165165                        ut2rgr.filldown ( ut,rgr ); 
    166166                        yt2rgr.filldown ( yt,rgr ); 
    167                         yt=impdf->samplecond ( rgr ); 
     167                        yt=ipdf->samplecond ( rgr ); 
    168168                        ut2rgr.step(ut); //u is now history 
    169169                } 
     
    177177                /*! 
    178178                \code 
    179                 class = "MpdfDS"; 
    180                 mpdf = {class="mpdf_offspring", ...};  // mpdf to simulate 
     179                class = "PdfDS"; 
     180                pdf = {class="pdf_offspring", ...};  // pdf to simulate 
    181181                --- optional --- 
    182182                init_rv = {class="RV",names=...};      // define what rv to initialize - typically delayed values! 
     
    187187                */ 
    188188                void from_setting ( const Setting &set ) { 
    189                         impdf=UI::build<mpdf> ( set,"mpdf",UI::compulsory ); 
     189                        ipdf=UI::build<pdf> ( set,"pdf",UI::compulsory ); 
    190190                         
    191                         Yrv = impdf->_rv(); 
     191                        Yrv = ipdf->_rv(); 
    192192                        // get unique rvs form rvc 
    193                         RV rgrv0=impdf->_rvc().remove_time(); 
     193                        RV rgrv0=ipdf->_rvc().remove_time(); 
    194194                        // input is what in not in Yrv 
    195195                        Urv=rgrv0.subt(Yrv);  
    196196                        set_drv(Yrv, Urv); 
    197197                        // connect input and output to rvc 
    198                         ut2rgr.set_connection(impdf->_rvc(), Urv);  
    199                         yt2rgr.set_connection(impdf->_rvc(), Yrv);  
     198                        ut2rgr.set_connection(ipdf->_rvc(), Urv);  
     199                        yt2rgr.set_connection(ipdf->_rvc(), Yrv);  
    200200                         
    201201                        //set history - if given 
     
    212212                        } 
    213213 
    214                         yt = zeros ( impdf->dimension() ); 
    215                         rgr = zeros ( impdf->dimensionc() ); 
     214                        yt = zeros ( ipdf->dimension() ); 
     215                        rgr = zeros ( ipdf->dimensionc() ); 
    216216                        ut = zeros(Urv._dsize()); 
    217217 
     
    225225                        ut2rgr.filldown ( ut,rgr ); 
    226226                        yt2rgr.filldown ( yt,rgr ); 
    227                         yt=impdf->samplecond ( rgr ); 
    228                 } 
    229 }; 
    230 UIREGISTER ( MpdfDS ); 
     227                        yt=ipdf->samplecond ( rgr ); 
     228                } 
     229}; 
     230UIREGISTER ( PdfDS ); 
    231231 
    232232/*! Pseudovirtual class for reading data from files 
     
    307307        private: 
    308308                //!conditional pdf of the state evolution \f$ f(x_t|x_{t-1}) \f$ 
    309                 shared_ptr<mpdf> IM; 
     309                shared_ptr<pdf> IM; 
    310310 
    311311                //!conditional pdf of the observations \f$ f(d_t|x_t) \f$ 
    312                 shared_ptr<mpdf> OM; 
     312                shared_ptr<pdf> OM; 
    313313 
    314314        protected: 
     
    331331                } 
    332332                //! 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 ), 
    334334                                dt ( OM0->dimension() ), xt ( IM0->dimension() ), 
    335335                                ut ( usize ), L_xt ( 0 ) { } 
     
    360360                        type = "stateDS"; 
    361361                        //Internal model 
    362                         IM = { type = "mpdf"; //<-- valid offspring! e.g. "mlnorm" 
     362                        IM = { type = "pdf"; //<-- valid offspring! e.g. "mlnorm" 
    363363                                rv = { //description of x_t 
    364364                                        names=["name1",...]; 
     
    373373                                }; 
    374374                        //Observation model 
    375                         OM = { type = "mpdf-offspring"; 
     375                        OM = { type = "pdf-offspring"; 
    376376                                rv = {}; //description of d_t 
    377377                                rvu = {type="internal", path="system.IM.rvu"}; //description of u_t