Show
Ignore:
Timestamp:
05/27/10 23:07:57 (14 years ago)
Author:
smidl
Message:

Mixtures example

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/estim/mixtures.cpp

    r1013 r1014  
    1818//      Coms(0)->set_evalll(false); 
    1919        Coms ( 0 )->bayes_batch ( Data ); 
    20         // Flatten it to its original shape 
    21         shared_ptr<BMEF> SharpCom((BMEF*)Coms(0)->_copy()); 
     20 
    2221        Coms ( 0 )->flatten ( Com0 );  
    2322 
     
    3433                } else { // pick at random 
    3534                        int ind = (int) floor ( ndat * UniRNG.sample() ); 
    36                         Coms ( i )->bayes_weighted ( Data.get_col ( ind ), empty_vec, ndat/Coms.length() ); 
     35                        Coms ( i )->bayes_weighted ( Data.get_col ( ind ), empty_vec, ndat ); 
     36                        Coms (i)->flatten(Com0,ndat/Coms.length()); 
    3737                } 
    3838                //sharpen to the sharp component 
    3939                //Coms ( i )->flatten ( SharpCom.get(), 1.0/Coms.length() ); 
    4040        } 
     41        MixEF_options old_opt =options; 
     42        MixEF_options ini_opt=options; 
     43        ini_opt.method = EM; 
     44        ini_opt.max_niter= 1; 
     45        bayes_batch(Data, empty_vec); 
     46         
     47        for ( i = 0; i < Coms.length(); i++ ) { 
     48                Coms (i)->flatten(Com0); 
     49        } 
     50         
     51        options = old_opt; 
    4152} 
    4253 
     
    8394 
    8495                        maxll = max ( ll, maxi ); 
    85                         switch ( method ) { 
     96                        switch ( options.method ) { 
    8697                        case QB: 
    8798                                w = exp ( ll - maxll );