Changeset 229 for bdm/estim/libPF.h

Show
Ignore:
Timestamp:
01/15/09 10:53:54 (16 years ago)
Author:
smidl
Message:

epdf has a new function: variance()

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/estim/libPF.h

    r225 r229  
    8888                        // ugly 
    8989                        vec pom=zeros ( ( Coms ( 0 )->_rv() ).count() ); 
    90  
    9190                        for ( int i=0; i<_w.length(); i++ ) {pom += Coms ( i )->mean() * _w ( i );} 
    92  
    9391                        return concat ( E.mean(),pom ); 
     92                } 
     93                vec variance() const { 
     94                        // ugly 
     95                        vec pom=zeros ( ( Coms ( 0 )->_rv() ).count() ); 
     96                        vec pom2=zeros ( ( Coms ( 0 )->_rv() ).count() ); 
     97                        for ( int i=0; i<_w.length(); i++ ) { 
     98                                pom += Coms ( i )->mean() * _w ( i ); 
     99                                pom2 += (Coms ( i )->variance() + pow(Coms(i)->mean(),2)) * _w ( i );} 
     100                        return concat ( E.variance(),pom2-pow(pom,2) ); 
    94101                } 
    95102