Changeset 565 for library/bdm/stat/exp_family.h
- Timestamp:
- 08/19/09 16:54:24 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/stat/exp_family.h
r536 r565 44 44 //! logarithm of the normalizing constant, \f$\mathcal{I}\f$ 45 45 virtual double lognc() const = 0; 46 46 47 //!Evaluate normalized log-probability 47 virtual double evallog_nn (const vec &val) const{it_error ("Not implemented");return 0.0;}; 48 virtual double evallog_nn (const vec &val) const { 49 bdm_error ("Not implemented"); 50 return 0.0; 51 } 52 48 53 //!Evaluate normalized log-probability 49 54 virtual double evallog (const vec &val) const { 50 55 double tmp; 51 56 tmp = evallog_nn (val) - lognc(); 52 // it_assert_debug ( std::isfinite ( tmp ),"Infinite value" );53 57 return tmp; 54 58 } … … 65 69 return x -lognc(); 66 70 } 71 67 72 //!Power of the density, used e.g. to flatten the density 68 virtual void pow (double p) {it_error ("Not implemented");}; 73 virtual void pow (double p) { 74 bdm_error ("Not implemented"); 75 } 69 76 }; 70 77 … … 84 91 BMEF (const BMEF &B) : BM (B), frg (B.frg), last_lognc (B.last_lognc) {} 85 92 //!get statistics from another model 86 virtual void set_statistics (const BMEF* BM0) {it_error ("Not implemented");}; 93 virtual void set_statistics (const BMEF* BM0) { 94 bdm_error ("Not implemented"); 95 } 96 87 97 //! Weighted update of sufficient statistics (Bayes rule) 88 98 virtual void bayes (const vec &data, const double w) {}; 89 99 //original Bayes 90 100 void bayes (const vec &dt); 101 91 102 //!Flatten the posterior according to the given BMEF (of the same type!) 92 virtual void flatten (const BMEF * B) {it_error ("Not implemented");} 93 //!Flatten the posterior as if to keep nu0 data 94 // virtual void flatten ( double nu0 ) {it_error ( "Not implemented" );} 95 96 BMEF* _copy_ () const {it_error ("function _copy_ not implemented for this BM"); return NULL;}; 103 virtual void flatten (const BMEF * B) { 104 bdm_error ("Not implemented"); 105 } 106 107 BMEF* _copy_ () const { 108 bdm_error ("function _copy_ not implemented for this BM"); 109 return NULL; 110 } 97 111 }; 98 112 … … 122 136 void from_setting (const Setting &root); 123 137 void validate() { 124 it_assert(mu.length() == R.rows(), "parameters mismatch");138 bdm_assert_debug (mu.length() == R.rows(), "parameters mismatch"); 125 139 dim = mu.length(); 126 140 } … … 272 286 //!@} 273 287 274 vec sample() const {it_error ("Not implemented");return vec_1 (0.0);}; 288 vec sample() const { 289 bdm_error ("Not implemented"); 290 return vec(); 291 } 292 275 293 vec mean() const {return beta / sum (beta);}; 276 294 vec variance() const {double gamma = sum (beta); return elem_mult (beta, (beta + 1)) / (gamma* (gamma + 1));} … … 278 296 double evallog_nn (const vec &val) const { 279 297 double tmp; tmp = (beta - 1) * log (val); 280 // it_assert_debug ( std::isfinite ( tmp ),"Infinite value" );281 298 return tmp; 282 }; 299 } 300 283 301 double lognc () const { 284 302 double tmp; … … 287 305 for (int i = 0;i < beta.length();i++) {lgb += lgamma (beta (i));} 288 306 tmp = lgb - lgamma (gam); 289 // it_assert_debug ( std::isfinite ( tmp ),"Infinite value" );290 307 return tmp; 291 }; 308 } 309 292 310 //!access function 293 311 vec& _beta() {return beta;} … … 397 415 } 398 416 void validate() { 399 it_assert(alpha.length() == beta.length(), "parameters do not match");417 bdm_assert_debug (alpha.length() == beta.length(), "parameters do not match"); 400 418 dim = alpha.length(); 401 419 } … … 446 464 void set_parameters( int &i, double wi, epdf* ep){w(i)=wi;Coms(i)=ep;} 447 465 vec mean(){vec pom; for(int i=0;i<n;i++){pom+=Coms(i)->mean()*w(i);} return pom;}; 448 vec sample() {it_error ( "Not implemented" );return 0;}449 466 }; 450 467 */ … … 472 489 void set_parameters (const vec &low0, const vec &high0) { 473 490 distance = high0 - low0; 474 it_assert_debug (min (distance) > 0.0, "bad support");491 bdm_assert_debug (min (distance) > 0.0, "bad support"); 475 492 low = low0; 476 493 high = high0; … … 535 552 //! Set \c A and \c R 536 553 void set_parameters (const mat &A0, const vec &mu0, const sq_T &R0) { 537 it_assert_debug (A0.rows() == mu0.length(), "");538 it_assert_debug (A0.rows() == R0.rows(), "");554 bdm_assert_debug (A0.rows() == mu0.length(), "mlnorm: A vs. mu mismatch"); 555 bdm_assert_debug (A0.rows() == R0.rows(), "mlnorm: A vs. R mismatch"); 539 556 540 557 this->iepdf.set_parameters (zeros (A0.rows()), R0); … … 660 677 //! constructor function 661 678 void set_parameters (const mat &A0, const vec &mu0, const ldmat &R0, const ldmat& Lambda0) { 662 it_assert_debug (A0.rows() == mu0.length(), "");663 it_assert_debug (R0.rows() == A0.rows(), "");679 bdm_assert_debug (A0.rows() == mu0.length(), "mlstudent: A vs. mu mismatch"); 680 bdm_assert_debug (R0.rows() == A0.rows(), "mlstudent: A vs. R mismatch"); 664 681 665 682 iepdf.set_parameters (mu0, Lambda); // … … 1138 1155 //! Function performs resampling, i.e. removal of low-weight samples and duplication of high-weight samples such that the new samples represent the same density. 1139 1156 ivec resample (RESAMPLING_METHOD method = SYSTEMATIC); 1140 //! inherited operation : NOT implemneted 1141 vec sample() const {it_error ("Not implemented");return 0;} 1142 //! inherited operation : NOT implemneted 1143 double evallog (const vec &val) const {it_error ("Not implemented");return 0.0;} 1157 1158 //! inherited operation : NOT implemented 1159 vec sample() const { 1160 bdm_error ("Not implemented"); 1161 return vec(); 1162 } 1163 1164 //! inherited operation : NOT implemented 1165 double evallog (const vec &val) const { 1166 bdm_error ("Not implemented"); 1167 return 0.0; 1168 } 1169 1144 1170 vec mean() const { 1145 1171 vec pom = zeros (dim); … … 1279 1305 void enorm<sq_T>::marginal ( const RV &rvn, enorm<sq_T> &target ) const 1280 1306 { 1281 it_assert_debug (isnamed(), "rv description is not assigned");1307 bdm_assert_debug (isnamed(), "rv description is not assigned"); 1282 1308 ivec irvn = rvn.dataind (rv); 1283 1309 … … 1302 1328 typedef mlnorm<sq_T> TMlnorm; 1303 1329 1304 it_assert_debug (isnamed(), "rvs are not assigned");1330 bdm_assert_debug (isnamed(), "rvs are not assigned"); 1305 1331 TMlnorm &uptarget = dynamic_cast<TMlnorm &>(target); 1306 1332 1307 1333 RV rvc = rv.subt (rvn); 1308 it_assert_debug ( (rvc._dsize() + rvn._dsize() == rv._dsize()), "wrong rvn");1334 bdm_assert_debug ( (rvc._dsize() + rvn._dsize() == rv._dsize()), "wrong rvn"); 1309 1335 //Permutation vector of the new R 1310 1336 ivec irvn = rvn.dataind (rv);