Changeset 678

Show
Ignore:
Timestamp:
10/22/09 15:18:50 (15 years ago)
Author:
smidl
Message:

finalizing transition mpdf->epdf

Location:
library/bdm
Files:
3 modified

Legend:

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

    r677 r678  
    393393        RV rvc; 
    394394 
    395         //! TODO 
     395        //! dimension of random variable 
    396396        int dim; 
    397397 
    398         //! TODO 
     398        //! random variable 
    399399        RV rv; 
    400400 
     
    479479        } 
    480480 
    481         bool isnamed() { 
     481        bool isnamed() const { 
    482482                return ( dim == rv._dsize() ) && ( dimc == rvc._dsize() ); 
    483483        } 
     
    488488//! Probability density function with numerical statistics, e.g. posterior density. 
    489489class epdf : public mpdf { 
    490 protected: 
    491         //! dimension of the random variable 
    492         int dim; 
    493         //! Description of the random variable 
    494         RV rv; 
    495490 
    496491public: 
     
    506501         All internal data structures are constructed as empty. Their values (including sizes) will be set by method \c set_parameters(). This way references can be initialized in constructors. 
    507502        @{*/ 
    508         epdf() : dim ( 0 ), rv() {}; 
    509         epdf ( const epdf &e ) : dim ( e.dim ), rv ( e.rv ) {}; 
    510         epdf ( const RV &rv0 ) : dim ( rv0._dsize() ) { 
    511                 set_rv ( rv0 ); 
    512         }; 
     503        epdf() {}; 
     504        epdf ( const epdf &e ) : mpdf(e) {}; 
    513505        void set_parameters ( int dim0 ) { 
    514506                dim = dim0; 
     
    574566        //! @{ 
    575567 
    576         //!Name its rv 
    577         void set_rv ( const RV &rv0 ) { 
    578                 rv = rv0; 
    579         } 
    580  
    581         //! True if rv is assigned 
    582         bool isnamed() const { 
    583                 bool b = ( dim == rv._dsize() ); 
    584                 return b; 
    585         } 
    586  
    587         //! Return name (fails when isnamed is false) 
    588         const RV& _rv() const { 
    589                 //bdm_assert_debug ( isnamed(), "" ); 
    590                 return rv; 
    591         } 
    592568        //! store values of the epdf on the following levels: 
    593569        //!  #1 mean 
     
    615591        //! @{ 
    616592 
    617         //! Size of the random variable 
    618         int dimension() const { 
    619                 return dim; 
    620         } 
    621593        //! Load from structure with elements: 
    622594        //!  \code 
     
    633605        } 
    634606 
    635  
    636 /*! \brief Unconditional mpdf, allows using epdf in the role of mpdf. 
    637  
    638 */ 
    639  
    640  
    641 /// MEPDF BEGINS HERE TODO 
    642         //! empty 
    643607        vec samplecond ( const vec &cond ) { 
    644608                return sample(); 
     
    683647        //! Efficient version of samplecond 
    684648        virtual mat samplecond_m ( const vec &cond, int N ); 
     649         
     650        void validate() { 
     651                iepdf.validate(); 
     652                if (rv._dsize()< iepdf._rv()._dsize()) {rv=iepdf._rv();}; 
     653                dim = iepdf.dimension(); 
     654        } 
    685655}; 
    686656 
  • library/bdm/stat/exp_family.cpp

    r665 r678  
    261261        iepdf.set_parameters ( k * ones ( beta0.length() ), beta0 ); 
    262262        dimc = iepdf.dimension(); 
     263        dim = iepdf.dimension(); 
    263264} 
    264265 
  • library/bdm/stat/exp_family.h

    r665 r678  
    408408                } 
    409409                void validate() {  
    410                         iepdf.validate(); 
     410                        mpdf_internal<eDirich>::validate(); 
    411411                        bdm_assert(_beta.length()==betac.length(),"beta0 and betac are not compatible"); 
    412412                        if (_rv()._dsize()>0){ 
     
    734734                }; 
    735735                void validate() { 
     736                        mpdf_internal<TEpdf<sq_T> >::validate(); 
    736737                        bdm_assert (A.rows() == mu_const.length(), "mlnorm: A vs. mu mismatch"); 
    737738                        bdm_assert (A.rows() == _R().rows(), "mlnorm: A vs. R mismatch"); 
     
    895896                        UI::get (k, set, "k", UI::compulsory); 
    896897                        set_parameters (k, betatmp); 
     898                        validate(); 
     899                } 
     900                void validate() { 
     901                        mpdf_internal<egamma>::validate(); 
     902                         
     903                        dim = _beta.length(); 
     904                        dimc = _beta.length(); 
    897905                } 
    898906};