Changeset 214 for bdm/stat/emix.h

Show
Ignore:
Timestamp:
11/27/08 23:31:48 (15 years ago)
Author:
smidl
Message:

debug asserts for infinite likelihoods

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/stat/emix.h

    r211 r214  
    6161        }; 
    6262        double evallogcond ( const vec &val, const vec &cond ) { 
     63                double tmp; 
    6364                vec nom_val ( rv.count() +rvc.count() ); 
    6465                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; 
    6669        } 
    6770        //! Object takes ownership of nom and will destroy it 
     
    106109                double sum = 0.0; 
    107110                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; 
    109115        }; 
    110116        vec evallog_m ( const mat &Val ) const { 
     
    115121                return log ( x ); 
    116122        }; 
     123        //! Auxiliary function that returns pdflog for each component 
    117124        mat evallog_M ( const mat &Val ) const { 
    118125                mat X ( w.length(), Val.cols() ); 
     
    249256                        tmp+=epdfs ( i )->evallog ( dls ( i )->get_val ( val ) ); 
    250257                } 
     258                it_assert_debug(std::isfinite(tmp),"Infinite"); 
    251259                return tmp; 
    252260        }