root/libPF.cpp @ 8

Revision 8, 1.0 kB (checked in by smidl, 16 years ago)

Kalmany funkci, PF nefunkci

Line 
1#include "libPF.h"
2
3using namespace itpp;
4
5using std::endl;
6
7ivec PF::resample( RESAMPLING_METHOD method ) {
8        ivec ind( n );
9        return ind;
10}
11
12TrivialPF::TrivialPF(mpdf &par0, mpdf &obs0, mpdf &prop0, int n0){
13        is_proposal = true;
14        prop = &prop0;
15        par = &par0;
16        obs = &obs0;
17}
18TrivialPF::TrivialPF(mpdf &par0, mpdf &obs0,  int n0){
19        is_proposal = false;
20        par = &par0;
21        obs = &obs0;
22}
23
24void TrivialPF::bayes( const vec &dt , bool evalll) {
25        int i;
26        vec oldp;
27        double ll, gl, sum=0.0;
28        Sort<double> S;
29        ivec ind, iw;
30        /*
31        //generate new samples
32        for ( i=0;i<n;i++ ) {
33                prop->evalcond( ptcls( i ), &prop_cond );
34                ptcls( i ) = prop_cond.sample();
35                gl = prop_cond.eval( ptcls( i ) );
36
37                obs.evalcond( ptcls( i ), &obs_cond );
38                ll = obs_cond.eval( dt );
39                w( i ) *= ll/gl;
40        }
41        //renormalize
42        for ( i=0;i<n;i++ ){sum+=w( i );};
43        w( i ) /=sum; //?
44        //
45        ind = resample();
46        iw = S.sort_index( 0,n-1,w ); // the first one in iw is the strongest
47
48        for ( i=0;i<n;i++ ) {
49                ptcls( i ) = ptcls( i ); //potentionally dangerous!
50        }
51        */
52}
Note: See TracBrowser for help on using the browser.