Changeset 678
- Timestamp:
- 10/22/09 15:18:50 (15 years ago)
- Location:
- library/bdm
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.h
r677 r678 393 393 RV rvc; 394 394 395 //! TODO395 //! dimension of random variable 396 396 int dim; 397 397 398 //! TODO398 //! random variable 399 399 RV rv; 400 400 … … 479 479 } 480 480 481 bool isnamed() {481 bool isnamed() const { 482 482 return ( dim == rv._dsize() ) && ( dimc == rvc._dsize() ); 483 483 } … … 488 488 //! Probability density function with numerical statistics, e.g. posterior density. 489 489 class epdf : public mpdf { 490 protected:491 //! dimension of the random variable492 int dim;493 //! Description of the random variable494 RV rv;495 490 496 491 public: … … 506 501 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. 507 502 @{*/ 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) {}; 513 505 void set_parameters ( int dim0 ) { 514 506 dim = dim0; … … 574 566 //! @{ 575 567 576 //!Name its rv577 void set_rv ( const RV &rv0 ) {578 rv = rv0;579 }580 581 //! True if rv is assigned582 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 }592 568 //! store values of the epdf on the following levels: 593 569 //! #1 mean … … 615 591 //! @{ 616 592 617 //! Size of the random variable618 int dimension() const {619 return dim;620 }621 593 //! Load from structure with elements: 622 594 //! \code … … 633 605 } 634 606 635 636 /*! \brief Unconditional mpdf, allows using epdf in the role of mpdf.637 638 */639 640 641 /// MEPDF BEGINS HERE TODO642 //! empty643 607 vec samplecond ( const vec &cond ) { 644 608 return sample(); … … 683 647 //! Efficient version of samplecond 684 648 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 } 685 655 }; 686 656 -
library/bdm/stat/exp_family.cpp
r665 r678 261 261 iepdf.set_parameters ( k * ones ( beta0.length() ), beta0 ); 262 262 dimc = iepdf.dimension(); 263 dim = iepdf.dimension(); 263 264 } 264 265 -
library/bdm/stat/exp_family.h
r665 r678 408 408 } 409 409 void validate() { 410 iepdf.validate();410 mpdf_internal<eDirich>::validate(); 411 411 bdm_assert(_beta.length()==betac.length(),"beta0 and betac are not compatible"); 412 412 if (_rv()._dsize()>0){ … … 734 734 }; 735 735 void validate() { 736 mpdf_internal<TEpdf<sq_T> >::validate(); 736 737 bdm_assert (A.rows() == mu_const.length(), "mlnorm: A vs. mu mismatch"); 737 738 bdm_assert (A.rows() == _R().rows(), "mlnorm: A vs. R mismatch"); … … 895 896 UI::get (k, set, "k", UI::compulsory); 896 897 set_parameters (k, betatmp); 898 validate(); 899 } 900 void validate() { 901 mpdf_internal<egamma>::validate(); 902 903 dim = _beta.length(); 904 dimc = _beta.length(); 897 905 } 898 906 };