Changeset 536 for library/bdm/stat/exp_family.h
- Timestamp:
- 08/16/09 18:13:31 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/stat/exp_family.h
r535 r536 44 44 //! logarithm of the normalizing constant, \f$\mathcal{I}\f$ 45 45 virtual double lognc() const = 0; 46 //!TODO decide if it is really needed47 virtual void dupdate (mat &v) {it_error ("Not implemented");};48 46 //!Evaluate normalized log-probability 49 47 virtual double evallog_nn (const vec &val) const{it_error ("Not implemented");return 0.0;}; … … 220 218 ldmat est_theta_cov() const; 221 219 220 //! expected values of the linear coefficient and the covariance matrix are written to \c M and \c R , respectively 222 221 void mean_mat (mat &M, mat&R) const; 223 222 //! In this instance, val= [theta, r]. For multivariate instances, it is stored columnwise val = [theta_1 theta_2 ... r_1 r_2 ] … … 340 339 if (evalll) {last_lognc = est.lognc();} 341 340 } 342 const epdf& posterior() const {return est;}; 343 const eDirich* _e() const {return &est;}; 341 //! reimplemnetation of BM::posterior() 342 const eDirich& posterior() const {return est;}; 343 //! constructor function 344 344 void set_parameters (const vec &beta0) { 345 345 est.set_parameters (beta0); … … 373 373 374 374 vec sample() const; 375 //! TODO: is it used anywhere?376 // mat sample ( int N ) const;377 375 double evallog (const vec &val) const; 378 376 double lognc () const; 379 //! Returns poi ter to alpha and beta. Potentially dengerous: use with care!377 //! Returns pointer to internal alpha. Potentially dengerous: use with care! 380 378 vec& _alpha() {return alpha;} 379 //! Returns pointer to internal beta. Potentially dengerous: use with care! 381 380 vec& _beta() {return beta;} 382 381 vec mean() const {return elem_div (alpha, beta);} … … 482 481 //!@} 483 482 484 double eval (const vec &val) const {return nk;}485 483 double evallog (const vec &val) const { 486 484 if (any (val < low) && any (val > high)) {return inf;} … … 516 514 \brief Normal distributed linear function with linear function of mean value; 517 515 518 Mean value \f$ mu=A*rvc+mu_0\f$.516 Mean value \f$ \mu=A*\mbox{rvc}+\mu_0 \f$. 519 517 */ 520 518 template < class sq_T, template <typename> class TEpdf = enorm > … … 524 522 //! Internal epdf that arise by conditioning on \c rvc 525 523 mat A; 524 //! Constant additive term 526 525 vec mu_const; 527 526 // vec& _mu; //cached epdf.mu; !!!!!! WHY NOT? … … 558 557 mat _R() { return this->iepdf._R().to_mat(); } 559 558 559 //! Debug stream 560 560 template<typename sq_M> 561 561 friend std::ostream &operator<< (std::ostream &os, mlnorm<sq_M, enorm> &ml); … … 649 649 { 650 650 protected: 651 //! Variable \f$ \Lambda \f$ from theory 651 652 ldmat Lambda; 653 //! Reference to variable \f$ R \f$ 652 654 ldmat &_R; 655 //! Variable \f$ R_e \f$ 653 656 ldmat Re; 654 657 public: 655 658 mlstudent () : mlnorm<ldmat, enorm> (), 656 659 Lambda (), _R (iepdf._R()) {} 660 //! constructor function 657 661 void set_parameters (const mat &A0, const vec &mu0, const ldmat &R0, const ldmat& Lambda0) { 658 662 it_assert_debug (A0.rows() == mu0.length(), ""); … … 968 972 double delta; 969 973 public: 974 //! Set internal structures 970 975 void set_parameters (const mat &Y0, const double delta0) {Y = chmat (Y0);delta = delta0; p = Y.rows(); dim = p * p; } 976 //! Sample matrix argument 971 977 mat sample_mat() const { 972 978 mat X = zeros (p, p); … … 998 1004 }; 999 1005 1006 //! Inverse Wishart on Choleski decomposition 1007 /*! Being computed by conversion from `standard' Wishart 1008 */ 1000 1009 class eiWishartCh: public epdf 1001 1010 { 1002 1011 protected: 1012 //! Internal instance of Wishart density 1003 1013 eWishartCh W; 1014 //! size of Ch 1004 1015 int p; 1016 //! parameter delta 1005 1017 double delta; 1006 1018 public: 1019 //! constructor function 1007 1020 void set_parameters (const mat &Y0, const double delta0) { 1008 1021 delta = delta0; … … 1011 1024 } 1012 1025 vec sample() const {mat iCh; iCh = inv (W.sample_mat()); return vec (iCh._data(), dim);} 1026 //! access function 1013 1027 void _setY (const vec &y0) { 1014 1028 mat Ch (p, p); … … 1044 1058 }; 1045 1059 1060 //! Random Walk on inverse Wishart 1046 1061 class rwiWishartCh : public mpdf_internal<eiWishartCh> 1047 1062 { … … 1049 1064 //!square root of \f$ \nu-p-1 \f$ - needed for computation of \f$ \Psi \f$ from conditions 1050 1065 double sqd; 1051 // reference point for diagonal1066 //!reference point for diagonal 1052 1067 vec refl; 1068 //! power of the reference 1053 1069 double l; 1070 //! dimension 1054 1071 int p; 1055 1072 1056 1073 public: 1057 1074 rwiWishartCh() : sqd (0), l (0), p (0) {} 1058 1075 //! constructor function 1059 1076 void set_parameters (int p0, double k, vec ref0, double l0) { 1060 1077 p = p0; … … 1326 1343 void mgnorm<sq_T >::condition (const vec &cond) {this->iepdf._mu() = g->eval (cond);}; 1327 1344 1345 //! \todo unify this stuff with to_string() 1328 1346 template<class sq_T> 1329 1347 std::ostream &operator<< (std::ostream &os, mlnorm<sq_T> &ml)