Changeset 229 for bdm/stat/emix.h
- Timestamp:
- 01/15/09 10:53:54 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/stat/emix.h
r224 r229 104 104 for ( i = 0;i < w.length();i++ ) {mu += w ( i ) * Coms ( i )->mean(); } 105 105 return mu; 106 } 107 vec variance() const { 108 //non-central moment 109 vec mom2 = zeros(rv.count()); 110 for ( int i = 0;i < w.length();i++ ) {mom2 += w ( i ) * pow(Coms ( i )->mean(),2); } 111 //central moment 112 return mom2-pow(mean(),2); 106 113 } 107 114 double evallog ( const vec &val ) const { … … 243 250 return tmp; 244 251 } 252 vec variance() const { 253 vec tmp ( rv.count() ); //second moment 254 for ( int i=0;i<epdfs.length();i++ ) { 255 vec pom = epdfs ( i )->mean(); 256 dls ( i )->fill_val ( tmp, pow(pom,2) ); 257 } 258 return tmp-pow(mean(),2); 259 } 245 260 vec sample() const { 246 261 vec tmp ( rv.count() );