root/library/tests/testResample.cpp @ 604

Revision 604, 0.7 kB (checked in by smidl, 15 years ago)

change of syntax of RV

  • Property svn:eol-style set to native
Line 
1
2#include "estim/particles.h"
3#include "math/square_mat.h"
4#include "stat/exp_family.h"
5
6using namespace bdm;
7
8//These lines are needed for use of cout and endl
9using std::cout;
10using std::endl;
11
12int main() {
13
14        RV x ( "1" );
15        RV xm = x;
16        xm.t_plus ( -1 );
17        const
18        RV y ( "2" );
19
20        mat A = "1";
21        vec vR = "1";
22        ldmat R ( vR );
23
24        eEmp emp;
25        euni eun;
26        eun.set_parameters ( "0", "1" );
27        emp.set_statistics ( ones ( 10 ), eun );
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
36        cout << "p:" << S << endl;
37        cout << "w:" << v << endl;
38
39        ivec ind = emp.resample();
40
41        cout << ind << endl;
42
43        //Exit program:
44        return 0;
45
46}
Note: See TracBrowser for help on using the browser.