Changeset 170 for bdm/stat/libBM.h

Show
Ignore:
Timestamp:
09/24/08 13:07:50 (16 years ago)
Author:
smidl
Message:

Mixtures of EF and related changes to libEF and BM

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/stat/libBM.h

    r168 r170  
    103103        //!access function 
    104104        std::string name ( int at ) {return names ( at );}; 
     105        //!Assign unused ids to this rv  
     106        void newids(); 
    105107}; 
    106108 
     
    144146        epdf ( const RV &rv0 ) :rv ( rv0 ) {}; 
    145147 
    146         //! Returns the required moment of the epdf 
     148//      //! Returns the required moment of the epdf 
    147149//      virtual vec moment ( const int order = 1 ); 
     150         
    148151        //! Returns a sample, \f$x\f$ from density \f$epdf(rv)\f$ 
    149152        virtual vec sample () const =0; 
     
    156159        virtual double evalpdflog ( const vec &val ) const =0; 
    157160 
     161        //! Compute log-probability of multiple values argument \c val 
     162        virtual vec evalpdflog ( const mat &Val ) const { 
     163                vec x ( Val.cols() ); 
     164                for ( int i=0;i<Val.cols();i++ ) {x ( i ) =evalpdflog( Val.get_col(i) ) ;} 
     165                return x; 
     166        } 
     167 
    158168        //! return expected value 
    159169        virtual vec mean() const =0; 
     
    162172        virtual ~epdf() {}; 
    163173        //! access function, possibly dangerous! 
    164         RV& _rv() {return rv;} 
     174        const RV& _rv() const {return rv;} 
     175        //! modifier function - useful when copying epdfs 
     176        void _renewrv(const RV &in_rv){rv=in_rv;} 
    165177}; 
    166178 
     
    270282 
    271283        //!Default constructor 
    272         BM ( const RV &rv0 ) :rv ( rv0 ), ll ( 0 ),evalll ( true ) {//Fixme: test rv 
     284        BM ( const RV &rv0, double ll0=0,bool evalll0=true ) :rv ( rv0 ), ll ( ll0 ),evalll ( evalll0) {//Fixme: test rv 
    273285        }; 
     286        //!Copy constructor 
     287        BM (const BM &B) : rv(B.rv), ll(B.ll), evalll(B.evalll) {} 
    274288 
    275289        /*! \brief Incremental Bayes rule 
     
    278292        virtual void bayes ( const vec &dt ) = 0; 
    279293        //! Batch Bayes rule (columns of Dt are observations) 
    280         void bayes ( mat Dt ); 
     294        virtual void bayesB (const mat &Dt ); 
    281295        //! Returns a pointer to the epdf representing posterior density on parameters. Use with care! 
    282         virtual epdf& _epdf() =0; 
    283  
     296        virtual const epdf& _epdf() const =0; 
     297 
     298        //! Evaluates predictive log-likelihood of the given data record 
     299        //! I.e. marginal likelihood of the data with the posterior integrated out. 
     300        virtual double logpred(const vec &dt)const{it_error("Not implemented");return 0.0;} 
     301         
    284302        //! Destructor for future use; 
    285303        virtual ~BM() {}; 
     
    290308        //!access function  
    291309        void set_evalll(bool evl0){evalll=evl0;} 
     310         
     311        //! Copy function required in vectors, Arrays of BM etc. Have to be DELETED manually! 
     312        //! Prototype: BM* _copy_(){BM Tmp*=new Tmp(this*);  return Tmp; } 
     313        virtual BM* _copy_(bool changerv=false){it_error("function _copy_ not implemented for this BM"); return NULL;}; 
    292314}; 
    293315