root/library/tests/testResample.cpp
@
645
Revision 645, 0.7 kB (checked in by smidl, 15 years ago) | |
---|---|
|
Rev | Line | |
---|---|---|
[262] | 1 | |
[386] | 2 | #include "estim/particles.h" |
3 | #include "math/square_mat.h" | |
4 | #include "stat/exp_family.h" | |
[32] | 5 | |
[254] | 6 | using namespace bdm; |
[32] | 7 | |
8 | //These lines are needed for use of cout and endl | |
9 | using std::cout; | |
10 | using std::endl; | |
11 | ||
12 | int main() { | |
13 | ||
[477] | 14 | RV x ( "1" ); |
15 | RV xm = x; | |
[604] | 16 | xm.t_plus ( -1 ); |
[477] | 17 | const |
18 | RV y ( "2" ); | |
19 | ||
[32] | 20 | mat A = "1"; |
21 | vec vR = "1"; | |
[477] | 22 | ldmat R ( vR ); |
23 | ||
[270] | 24 | eEmp emp; |
25 | euni eun; | |
[477] | 26 | eun.set_parameters ( "0", "1" ); |
[488] | 27 | emp.set_statistics ( ones ( 10 ), eun ); |
[477] | 28 | vec &v = emp._w(); |
29 | Array<vec> &S = emp._samples(); | |
30 | ||
31 | for ( int i = 0; i < 10; i++ ) { | |
32 | v ( i ) = exp ( -0.5 * sum ( pow ( S ( i ) - 1, 2.0 ) ) * 10 ); | |
33 | } | |
34 | v /= sum ( v ); | |
35 | ||
[32] | 36 | cout << "p:" << S << endl; |
37 | cout << "w:" << v << endl; | |
[477] | 38 | |
[645] | 39 | ivec ind; |
40 | emp.resample(ind); | |
[477] | 41 | |
[32] | 42 | cout << ind << endl; |
[477] | 43 | |
[32] | 44 | //Exit program: |
45 | return 0; | |
46 | ||
47 | } |
Note: See TracBrowser
for help on using the browser.