Changeset 693 for library/bdm

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
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/CMakeLists.txt

    r692 r693  
    1818IF(WIN32) 
    1919   SET(bdm_support ${bdm_support} dirent.c dirent.h) 
    20    ADD_DEFINITIONS(-DLIBCONFIG_STATIC -DLIBCONFIGXX_STATIC) 
    2120ENDIF() 
    2221 
  • 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 
  • library/bdm/estim/particles.h

    r686 r693  
    3636        Array<vec> &_samples; 
    3737        //! Parameter evolution model 
    38         shared_ptr<mpdf> par; 
     38        shared_ptr<pdf> par; 
    3939        //! Observation model 
    40         shared_ptr<mpdf> obs; 
     40        shared_ptr<pdf> obs; 
    4141        //! internal structure storing loglikelihood of predictions 
    4242        vec lls; 
     
    6363                resmethod = rm; 
    6464        }; 
    65         void set_model ( shared_ptr<mpdf> par0, shared_ptr<mpdf> obs0) { 
     65        void set_model ( shared_ptr<pdf> par0, shared_ptr<pdf> obs0) { 
    6666                par = par0; 
    6767                obs = obs0; 
     
    105105        /*! configuration structure for basic PF 
    106106        \code 
    107         parameter_pdf   = mpdf_class;         // parameter evolution pdf 
    108         observation_pdf = mpdf_class;         // observation pdf 
     107        parameter_pdf   = pdf_class;         // parameter evolution pdf 
     108        observation_pdf = pdf_class;         // observation pdf 
    109109        prior           = epdf_class;         // prior probability density 
    110110        --- optional --- 
     
    117117        void from_setting(const Setting &set){ 
    118118                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); 
    121121                 
    122122                prior_from_set(set); 
     
    196196 
    197197A 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 MPFmpdf. 
     198The Bayesian models provide marginalized predictive density. Internaly this is achieved by virtual class MPFpdf. 
    199199*/ 
    200200 
     
    206206        Array<BM*> BMs; 
    207207 
    208         //! internal class for MPDF providing composition of eEmp with external components 
     208        //! internal class for pdf providing composition of eEmp with external components 
    209209 
    210210        class mpfepdf : public epdf  { 
     
    306306        MPF () :  jest (pf,BMs) {}; 
    307307        //! 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 ) { 
    309309                pf->set_model ( par0, obs0);  
    310310                pf->set_parameters(n0, rm ); 
     
    341341        \code 
    342342        BM              = BM_class;           // Bayesian filtr for analytical part of the model 
    343         parameter_pdf   = mpdf_class;         // transitional pdf for non-parametric part of the model 
     343        parameter_pdf   = pdf_class;         // transitional pdf for non-parametric part of the model 
    344344        prior           = epdf_class;         // prior probability density 
    345345        --- optional --- 
     
    350350        */       
    351351        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!! 
    354354 
    355355                pf = new PF; 
  • library/bdm/stat/emix.cpp

    r675 r693  
    5454} 
    5555 
    56 shared_ptr<mpdf> emix::condition ( const RV &rv ) const { 
     56shared_ptr<pdf> emix::condition ( const RV &rv ) const { 
    5757        bdm_assert ( isnamed(), "rvs are not assigned" ); 
    5858        mratio *tmp = new mratio ( this, rv ); 
    59         return shared_ptr<mpdf>(tmp); 
     59        return shared_ptr<pdf>(tmp); 
    6060} 
    6161 
     
    203203}; 
    204204 
    205 void mprod::set_elements (const Array<shared_ptr<mpdf> > &mFacs ) { 
    206         mpdfs = mFacs; 
     205void mprod::set_elements (const Array<shared_ptr<pdf> > &mFacs ) { 
     206        pdfs = mFacs; 
    207207        dls.set_size ( mFacs.length() ); 
    208208 
    209         rv = get_composite_rv ( mpdfs, true ); 
     209        rv = get_composite_rv ( pdfs, true ); 
    210210        dim = rv._dsize(); 
    211211 
    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 ); 
    214214                rvc.add ( rvx ); // add rv to common rvc 
    215215        } 
    216216        dimc=rvc._dsize(); 
    217217 
    218         // rv and rvc established = > we can link them with mpdfs 
    219         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++ ) { 
    220220                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() ); 
    222222        } 
    223223} 
     
    239239 
    240240} 
    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 ) { 
    242242//              int i; 
    243243//              bool rvaddok; 
    244244//              // Create rv 
    245245//              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 epdf 
     246//                      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 
    249249//              }; 
    250250//              // Create rvc 
    251251//              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. 
    253253//              }; 
    254254// 
    255255// //           independent = true; 
    256 //              //test rvc of mpdfs and fill rvinds 
     256//              //test rvc of pdfs and fill rvinds 
    257257//              for ( i = 0;i < n;i++ ) { 
    258258//                      // find ith rv in common rv 
    259 //                      rvsinrv ( i ) = mpdfs ( i )->_rv().dataind ( rv ); 
     259//                      rvsinrv ( i ) = pdfs ( i )->_rv().dataind ( rv ); 
    260260//                      // find ith rvc in common rv 
    261 //                      rvcinrv ( i ) = mpdfs ( i )->_rvc().dataind ( rv ); 
     261//                      rvcinrv ( i ) = pdfs ( i )->_rvc().dataind ( rv ); 
    262262//                      // find ith rvc in common rv 
    263 //                      irvcs_rvc ( i ) = mpdfs ( i )->_rvc().dataind ( rvc ); 
     263//                      irvcs_rvc ( i ) = pdfs ( i )->_rvc().dataind ( rvc ); 
    264264//                      // 
    265265// /*                   if ( rvcinrv ( i ).length() >0 ) {independent = false;} 
  • library/bdm/stat/emix.h

    r675 r693  
    3535At present the only supported operation is evallogcond(). 
    3636 */ 
    37 class mratio: public mpdf { 
     37class mratio: public pdf { 
    3838protected: 
    39         //! Nominator in the form of mpdf 
     39        //! Nominator in the form of pdf 
    4040        const epdf* nom; 
    4141 
     
    5050        //!Default constructor. By default, the given epdf is not copied! 
    5151        //! 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 ( ) { 
    5353                // adjust rv and rvc 
    5454 
     
    178178        //! Update already existing marginal density  \c target 
    179179        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; 
    181181 
    182182//Access methods 
     
    283283Note that 
    284284*/ 
    285 class mprod: public mpdf { 
     285class mprod: public pdf { 
    286286private: 
    287         Array<shared_ptr<mpdf> > mpdfs; 
    288  
    289         //! Data link for each mpdfs 
     287        Array<shared_ptr<pdf> > pdfs; 
     288 
     289        //! Data link for each pdfs 
    290290        Array<shared_ptr<datalink_m2m> > dls; 
    291291 
     
    300300        /*!\brief Constructor from list of mFacs 
    301301        */ 
    302         mprod ( const Array<shared_ptr<mpdf> > &mFacs ) { 
     302        mprod ( const Array<shared_ptr<pdf> > &mFacs ) { 
    303303                set_elements ( mFacs ); 
    304304        } 
    305         //! Set internal \c mpdfs from given values 
    306         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 ); 
    307307 
    308308        double evallogcond ( const vec &val, const vec &cond ) { 
    309309                int i; 
    310310                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 ) ); 
    314314                                                } 
    315315                                                // add logarithms 
    316316                                                res += epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) );*/ 
    317                         res += mpdfs ( i )->evallogcond ( 
     317                        res += pdfs ( i )->evallogcond ( 
    318318                                   dls ( i )->pushdown ( val ), 
    319319                                   dls ( i )->get_cond ( val, cond ) 
     
    344344                vec smpi; 
    345345                // 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 mpdf 
    348                         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 ));                  
    349349                        // copy contribution of this pdf into smp 
    350350                        dls ( i )->pushup ( smp, smpi ); 
     
    356356        //!  \code 
    357357        //! { class='mprod'; 
    358         //!   mpdfs = (..., ...);     // list of mpdfs in the order of chain rule 
     358        //!   pdfs = (..., ...);     // list of pdfs in the order of chain rule 
    359359        //! } 
    360360        //! \endcode 
    361361        //!@} 
    362362        void from_setting ( const Setting &set ) { 
    363                 Array<shared_ptr<mpdf> > atmp; //temporary Array 
    364                 UI::get ( atmp, set, "mpdfs", UI::compulsory ); 
     363                Array<shared_ptr<pdf> > atmp; //temporary Array 
     364                UI::get ( atmp, set, "pdfs", UI::compulsory ); 
    365365                set_elements ( atmp ); 
    366366        } 
     
    460460 
    461461 
    462 /*! \brief Mixture of mpdfs with constant weights, all mpdfs are of equal RV and RVC 
     462/*! \brief Mixture of pdfs with constant weights, all pdfs are of equal RV and RVC 
    463463 
    464464*/ 
    465 class mmix : public mpdf { 
     465class mmix : public pdf { 
    466466protected: 
    467         //! Component (mpdfs) 
    468         Array<shared_ptr<mpdf> > Coms; 
     467        //! Component (pdfs) 
     468        Array<shared_ptr<pdf> > Coms; 
    469469        //!weights of the components 
    470470        vec w; 
     
    474474 
    475475        //! 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 ) { 
    477477                //!\todo check if all components are OK 
    478478                Coms = Coms0; 
  • library/bdm/stat/exp_family.h

    r679 r693  
    163163                vec variance() const {return diag (R.to_mat());} 
    164164//      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; 
    166166 
    167167                // target not typed to mlnorm<sq_T, enorm<sq_T> > & 
     
    169169                // haven't finished defining enorm yet), but the type 
    170170                // is required 
    171                 void condition ( const RV &rvn, mpdf &target ) const; 
     171                void condition ( const RV &rvn, pdf &target ) const; 
    172172 
    173173                shared_ptr<epdf> marginal (const RV &rvn ) const; 
     
    367367*/ 
    368368 
    369 class mDirich: public mpdf_internal<eDirich> { 
     369class mDirich: public pdf_internal<eDirich> { 
    370370        protected: 
    371371                //! constant \f$ k \f$ of the random walk 
     
    376376                vec betac; 
    377377        public: 
    378                 mDirich(): mpdf_internal<eDirich>(), _beta(iepdf._beta()){}; 
     378                mDirich(): pdf_internal<eDirich>(), _beta(iepdf._beta()){}; 
    379379                void condition (const vec &val) {_beta =  val/k+betac; }; 
    380380                /*! Create Dirichlet random walk  
     
    391391                */ 
    392392                void from_setting (const Setting &set) { 
    393                         mpdf::from_setting (set); // reads rv and rvc 
     393                        pdf::from_setting (set); // reads rv and rvc 
    394394                        if (_rv()._dsize()>0){ 
    395395                                rvc = _rv().copy_t(-1); 
     
    408408                } 
    409409                void validate() {  
    410                         mpdf_internal<eDirich>::validate(); 
     410                        pdf_internal<eDirich>::validate(); 
    411411                        bdm_assert(_beta.length()==betac.length(),"beta0 and betac are not compatible"); 
    412412                        if (_rv()._dsize()>0){ 
     
    644644 
    645645//! Uniform density with conditional mean value 
    646 class mguni : public mpdf_internal<euni>{ 
     646class mguni : public pdf_internal<euni>{ 
    647647        //! function of the mean value 
    648648        shared_ptr<fnc> mean; 
     
    656656                //! load from 
    657657                void from_setting(const Setting &set){ 
    658                         mpdf::from_setting(set); //reads rv and rvc 
     658                        pdf::from_setting(set); //reads rv and rvc 
    659659                        UI::get(delta,set,"delta",UI::compulsory); 
    660660                        mean = UI::build<fnc>(set,"mean",UI::compulsory); 
     
    672672*/ 
    673673template < class sq_T, template <typename> class TEpdf = enorm > 
    674 class mlnorm : public mpdf_internal< TEpdf<sq_T> > 
     674class mlnorm : public pdf_internal< TEpdf<sq_T> > 
    675675{ 
    676676        protected: 
     
    683683                //! \name Constructors 
    684684                //!@{ 
    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> >() { 
    687687                        set_parameters (A, mu0, R); 
    688688                } 
     
    724724                */ 
    725725                void from_setting (const Setting &set) { 
    726                         mpdf::from_setting (set); 
     726                        pdf::from_setting (set); 
    727727 
    728728                        UI::get (A, set, "A", UI::compulsory); 
     
    734734                }; 
    735735                void validate() { 
    736                         mpdf_internal<TEpdf<sq_T> >::validate(); 
     736                        pdf_internal<TEpdf<sq_T> >::validate(); 
    737737                        bdm_assert (A.rows() == mu_const.length(), "mlnorm: A vs. mu mismatch"); 
    738738                        bdm_assert (A.rows() == _R().rows(), "mlnorm: A vs. R mismatch"); 
     
    747747SHAREDPTR2 ( mlnorm, chmat ); 
    748748 
    749 //! Mpdf with general function for mean value 
     749//! pdf with general function for mean value 
    750750template<class sq_T> 
    751 class mgnorm : public mpdf_internal< enorm< sq_T > > 
     751class mgnorm : public pdf_internal< enorm< sq_T > > 
    752752{ 
    753753        private: 
     
    757757        public: 
    758758                //!default constructor 
    759                 mgnorm() : mpdf_internal<enorm<sq_T> >() { } 
     759                mgnorm() : pdf_internal<enorm<sq_T> >() { } 
    760760                //!set mean function 
    761761                inline void set_parameters (const shared_ptr<fnc> &g0, const sq_T &R0); 
     
    782782 
    783783                void from_setting (const Setting &set) { 
    784                         mpdf::from_setting(set); 
     784                        pdf::from_setting(set); 
    785785                        shared_ptr<fnc> g = UI::build<fnc> (set, "g", UI::compulsory); 
    786786 
     
    863863The standard deviation of the walk is then: \f$\mu/\sqrt(k)\f$. 
    864864*/ 
    865 class mgamma : public mpdf_internal<egamma> 
     865class mgamma : public pdf_internal<egamma> 
    866866{ 
    867867        protected: 
     
    875875        public: 
    876876                //! Constructor 
    877                 mgamma() : mpdf_internal<egamma>(), k (0), 
     877                mgamma() : pdf_internal<egamma>(), k (0), 
    878878                                _beta (iepdf._beta()) { 
    879879                } 
     
    895895                */ 
    896896                void from_setting (const Setting &set) { 
    897                         mpdf::from_setting (set); // reads rv and rvc 
     897                        pdf::from_setting (set); // reads rv and rvc 
    898898                        vec betatmp; // ugly but necessary 
    899899                        UI::get (betatmp, set, "beta", UI::compulsory); 
     
    903903                } 
    904904                void validate() { 
    905                         mpdf_internal<egamma>::validate(); 
     905                        pdf_internal<egamma>::validate(); 
    906906                         
    907907                        dim = _beta.length(); 
     
    921921The standard deviation of the walk is then: \f$ \mu/\sqrt(k)\f$. 
    922922 */ 
    923 class migamma : public mpdf_internal<eigamma> 
     923class migamma : public pdf_internal<eigamma> 
    924924{ 
    925925        protected: 
     
    936936                //! \name Constructors 
    937937                //!@{ 
    938                 migamma() : mpdf_internal<eigamma>(), 
     938                migamma() : pdf_internal<eigamma>(), 
    939939                                k (0), 
    940940                                _alpha (iepdf._alpha()), 
     
    942942                } 
    943943 
    944                 migamma (const migamma &m) : mpdf_internal<eigamma>(), 
     944                migamma (const migamma &m) : pdf_internal<eigamma>(), 
    945945                                k (0), 
    946946                                _alpha (iepdf._alpha()), 
     
    10741074 
    10751075 */ 
    1076 class mlognorm : public mpdf_internal<elognorm> 
     1076class mlognorm : public pdf_internal<elognorm> 
    10771077{ 
    10781078        protected: 
     
    10841084        public: 
    10851085                //! Constructor 
    1086                 mlognorm() : mpdf_internal<elognorm>(), 
     1086                mlognorm() : pdf_internal<elognorm>(), 
    10871087                                sig2 (0), 
    10881088                                mu (iepdf._mu()) { 
     
    12211221 
    12221222//! Random Walk on inverse Wishart 
    1223 class rwiWishartCh : public mpdf_internal<eiWishartCh> 
     1223class rwiWishartCh : public pdf_internal<eiWishartCh> 
    12241224{ 
    12251225        protected: 
     
    14741474 
    14751475template<class sq_T> 
    1476 shared_ptr<mpdf> enorm<sq_T>::condition ( const RV &rvn ) const 
     1476shared_ptr<pdf> enorm<sq_T>::condition ( const RV &rvn ) const 
    14771477{ 
    14781478        mlnorm<sq_T> *tmp = new mlnorm<sq_T> (); 
    1479         shared_ptr<mpdf> narrow(tmp); 
     1479        shared_ptr<pdf> narrow(tmp); 
    14801480        condition ( rvn, *tmp ); 
    14811481        return narrow; 
     
    14831483 
    14841484template<class sq_T> 
    1485 void enorm<sq_T>::condition ( const RV &rvn, mpdf &target ) const 
     1485void enorm<sq_T>::condition ( const RV &rvn, pdf &target ) const 
    14861486{ 
    14871487        typedef mlnorm<sq_T> TMlnorm; 
  • library/bdm/stat/merger.cpp

    r682 r693  
    55namespace bdm { 
    66 
    7 merger_base::merger_base ( const Array<shared_ptr<mpdf> > &S ): 
     7merger_base::merger_base ( const Array<shared_ptr<pdf> > &S ): 
    88        Npoints(0), DBG(false), dbg_file(0) { 
    99        set_sources ( S ); 
     
    134134 
    135135 
    136                         sprintf ( dbg_str, "Mpdf%d", niter ); 
     136                        sprintf ( dbg_str, "pdf%d", niter ); 
    137137                        for ( int i = 0; i < Npoints; i++ ) { 
    138138                                Mix_pdf ( i ) = Mix.logpred ( Smp_ex.get_col ( i ) ); 
     
    145145                } 
    146146                //Importace weighting 
    147                 for ( int i = 0; i < mpdfs.length(); i++ ) { 
     147                for ( int i = 0; i < pdfs.length(); i++ ) { 
    148148                        lw_src = 0.0; 
    149149                        //======== Same RVs =========== 
    150150                        //Split according to dependency in rvs 
    151                         if ( mpdfs ( i )->dimension() == dim ) { 
     151                        if ( pdfs ( i )->dimension() == dim ) { 
    152152                                // 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)); 
    154154                        } else { 
    155155                                // compute likelihood of marginal on the conditional variable 
    156                                 if ( mpdfs ( i )->dimensionc() > 0 ) { 
     156                                if ( pdfs ( i )->dimensionc() > 0 ) { 
    157157                                        // 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() ); 
    159159                                        //compute vector of lw_src 
    160160                                        for ( int k = 0; k < Npoints; k++ ) { 
    161                                                 // Here val of tmp_marg = cond of mpdfs(i) ==> calling dls->get_cond 
     161                                                // Here val of tmp_marg = cond of pdfs(i) ==> calling dls->get_cond 
    162162                                                lw_src ( k ) += tmp_marg->evallog ( dls ( i )->get_cond ( Smp ( k ) ) ); 
    163163                                        } 
     
    168168                                } 
    169169                                // Compute likelihood of the missing variable 
    170                                 if ( dim > ( mpdfs ( i )->dimension() + mpdfs ( i )->dimensionc() ) ) { 
     170                                if ( dim > ( pdfs ( i )->dimension() + pdfs ( i )->dimensionc() ) ) { 
    171171                                        /////////////// 
    172                                         // There are variales unknown to mpdfs(i) : rvzs 
    173                                         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 ) ); 
    174174                                        // Compute likelihood 
    175175                                        vec lw_dbg = lw_src; 
     
    187187                                // Compute likelihood of the partial source 
    188188                                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 ) ),   
    190190                                                         dls ( i )->get_cond ( Smp ( k ) )); 
    191191                                } 
  • library/bdm/stat/merger.h

    r679 r693  
    4646protected: 
    4747        //! Elements of composition 
    48         Array<shared_ptr<mpdf> > mpdfs; 
    49  
    50         //! Data link for each mpdf in mpdfs 
     48        Array<shared_ptr<pdf> > pdfs; 
     49 
     50        //! Data link for each pdf in pdfs 
    5151        Array<datalink_m2e*> dls; 
    5252 
    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$ 
    5454        Array<RV> rvzs; 
    5555 
     
    9090 
    9191        //!Constructor from sources 
    92         merger_base ( const Array<shared_ptr<mpdf> > &S ); 
     92        merger_base ( const Array<shared_ptr<pdf> > &S ); 
    9393 
    9494        //! 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(); 
    9898                //set sizes 
    9999                dls.set_size ( Sources.length() ); 
     
    101101                zdls.set_size ( Sources.length() ); 
    102102 
    103                 rv = get_composite_rv ( mpdfs, /* checkoverlap = */ false ); 
     103                rv = get_composite_rv ( pdfs, /* checkoverlap = */ false ); 
    104104 
    105105                RV rvc; 
    106106                // 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 ); 
    109109                        rvc.add ( rvx ); // add rv to common rvc 
    110110                } 
     
    117117                // create links between sources and common rv 
    118118                RV xytmp; 
    119                 for ( int i = 0; i < mpdfs.length(); i++ ) { 
    120                         //Establich connection between mpdfs and merger 
     119                for ( int i = 0; i < pdfs.length(); i++ ) { 
     120                        //Establich connection between pdfs and merger 
    121121                        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 mpdf 
    125                         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() ); 
    127127                        // z_i = common_rv-xy 
    128128                        rvzs ( i ) = rv.subt ( xytmp ); 
     
    185185                //check if sources overlap: 
    186186                bool OK = true; 
    187                 for ( int i = 0; i < mpdfs.length(); i++ ) { 
     187                for ( int i = 0; i < pdfs.length(); i++ ) { 
    188188                        OK &= ( rvzs ( i )._dsize() == 0 ); // z_i is empty 
    189                         OK &= ( mpdfs ( i )->_rvc()._dsize() == 0 ); // y_i is empty 
     189                        OK &= ( pdfs ( i )->_rvc()._dsize() == 0 ); // y_i is empty 
    190190                } 
    191191 
    192192                if ( OK ) { 
    193                         mat lW = zeros ( mpdfs.length(), eSmp._w().length() ); 
     193                        mat lW = zeros ( pdfs.length(), eSmp._w().length() ); 
    194194 
    195195                        vec emptyvec ( 0 ); 
    196                         for ( int i = 0; i < mpdfs.length(); i++ ) { 
     196                        for ( int i = 0; i < pdfs.length(); i++ ) { 
    197197                                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 ); 
    199199                                } 
    200200                        } 
     
    313313        merger_mix ():Ncoms(0), effss_coef(0), stop_niter(0) { } 
    314314 
    315         merger_mix ( const Array<shared_ptr<mpdf> > &S ): 
     315        merger_mix ( const Array<shared_ptr<pdf> > &S ): 
    316316                Ncoms(0), effss_coef(0), stop_niter(0) { 
    317317                set_sources ( S ); 
     
    319319 
    320320        //! 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 ) { 
    322322                merger_base::set_sources ( S ); 
    323323                Nsources = S.length();