Show
Ignore:
Timestamp:
11/25/09 18:02:21 (14 years ago)
Author:
mido
Message:

the rest of h to cpp movements, with exception of from_setting and validate to avoid conflicts with Sarka

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/estim/particles.h

    r737 r739  
    236236                        bdm_assert_debug ( dim == rv._dsize(), "Wrong name " ); 
    237237                } 
    238                 vec mean() const { 
    239                         const vec &w = pf->posterior()._w(); 
    240                         vec pom = zeros ( BMs ( 0 )->posterior ().dimension() ); 
    241                         //compute mean of BMs 
    242                         for ( int i = 0; i < w.length(); i++ ) { 
    243                                 pom += BMs ( i )->posterior().mean() * w ( i ); 
    244                         } 
    245                         return concat ( pf->posterior().mean(), pom ); 
    246                 } 
    247                 vec variance() const { 
    248                         const vec &w = pf->posterior()._w(); 
    249  
    250                         vec pom = zeros ( BMs ( 0 )->posterior ().dimension() ); 
    251                         vec pom2 = zeros ( BMs ( 0 )->posterior ().dimension() ); 
    252                         vec mea; 
    253  
    254                         for ( int i = 0; i < w.length(); i++ ) { 
    255                                 // save current mean 
    256                                 mea = BMs ( i )->posterior().mean(); 
    257                                 pom += mea * w ( i ); 
    258                                 //compute variance 
    259                                 pom2 += ( BMs ( i )->posterior().variance() + pow ( mea, 2 ) ) * w ( i ); 
    260                         } 
    261                         return concat ( pf->posterior().variance(), pom2 - pow ( pom, 2 ) ); 
    262                 } 
    263  
    264                 void qbounds ( vec &lb, vec &ub, double perc = 0.95 ) const { 
    265                         //bounds on particles 
    266                         vec lbp; 
    267                         vec ubp; 
    268                         pf->posterior().qbounds ( lbp, ubp ); 
    269  
    270                         //bounds on Components 
    271                         int dimC = BMs ( 0 )->posterior().dimension(); 
    272                         int j; 
    273                         // temporary 
    274                         vec lbc ( dimC ); 
    275                         vec ubc ( dimC ); 
    276                         // minima and maxima 
    277                         vec Lbc ( dimC ); 
    278                         vec Ubc ( dimC ); 
    279                         Lbc = std::numeric_limits<double>::infinity(); 
    280                         Ubc = -std::numeric_limits<double>::infinity(); 
    281  
    282                         for ( int i = 0; i < BMs.length(); i++ ) { 
    283                                 // check Coms 
    284                                 BMs ( i )->posterior().qbounds ( lbc, ubc ); 
    285                                 //save either minima or maxima 
    286                                 for ( j = 0; j < dimC; j++ ) { 
    287                                         if ( lbc ( j ) < Lbc ( j ) ) { 
    288                                                 Lbc ( j ) = lbc ( j ); 
    289                                         } 
    290                                         if ( ubc ( j ) > Ubc ( j ) ) { 
    291                                                 Ubc ( j ) = ubc ( j ); 
    292                                         } 
    293                                 } 
    294                         } 
    295                         lb = concat ( lbp, Lbc ); 
    296                         ub = concat ( ubp, Ubc ); 
    297                 } 
     238                vec mean() const; 
     239 
     240                vec variance() const; 
     241 
     242                void qbounds ( vec &lb, vec &ub, double perc = 0.95 ) const; 
    298243 
    299244                vec sample() const {