Changeset 214 for bdm/stat/emix.h
- Timestamp:
- 11/27/08 23:31:48 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/stat/emix.h
r211 r214 61 61 }; 62 62 double evallogcond ( const vec &val, const vec &cond ) { 63 double tmp; 63 64 vec nom_val ( rv.count() +rvc.count() ); 64 65 dl.fill_val_cond ( nom_val,val,cond ); 65 return exp ( nom->evallog ( nom_val ) - den->evallog ( cond ) ); 66 tmp = exp ( nom->evallog ( nom_val ) - den->evallog ( cond ) ); 67 it_assert_debug(std::isfinite(tmp),"Infinite value"); 68 return tmp; 66 69 } 67 70 //! Object takes ownership of nom and will destroy it … … 106 109 double sum = 0.0; 107 110 for ( i = 0;i < w.length();i++ ) {sum += w ( i ) * exp ( Coms ( i )->evallog ( val ) );} 108 return log ( sum ); 111 if (sum==0.0){sum=std::numeric_limits<double>::epsilon();} 112 double tmp=log ( sum ); 113 it_assert_debug(std::isfinite(tmp),"Infinite"); 114 return tmp; 109 115 }; 110 116 vec evallog_m ( const mat &Val ) const { … … 115 121 return log ( x ); 116 122 }; 123 //! Auxiliary function that returns pdflog for each component 117 124 mat evallog_M ( const mat &Val ) const { 118 125 mat X ( w.length(), Val.cols() ); … … 249 256 tmp+=epdfs ( i )->evallog ( dls ( i )->get_val ( val ) ); 250 257 } 258 it_assert_debug(std::isfinite(tmp),"Infinite"); 251 259 return tmp; 252 260 }