1 | #include <itpp/itbase.h> |
---|
2 | #include <stat/libEF.h> |
---|
3 | #include <estim/merger.h> |
---|
4 | |
---|
5 | using namespace itpp; |
---|
6 | |
---|
7 | //These lines are needed for use of cout and endl |
---|
8 | using std::cout; |
---|
9 | using std::endl; |
---|
10 | |
---|
11 | int main() { |
---|
12 | |
---|
13 | //RNG_randomize(); |
---|
14 | |
---|
15 | RV x ( "{x }","1" ); |
---|
16 | RV y ( "{y }","1" ); |
---|
17 | |
---|
18 | RV xy=x; xy.add(y); |
---|
19 | |
---|
20 | enorm<fsqmat> f1 ( xy ); |
---|
21 | enorm<fsqmat> f2 ( x ); |
---|
22 | |
---|
23 | f1.set_parameters ( "3 2",mat ( "0.5 0; 0 0.5" ) ); |
---|
24 | f2.set_parameters ( "3",mat ( "0.5" ) ); |
---|
25 | |
---|
26 | Array<mpdf* > A ( 2 ); |
---|
27 | mepdf A1(f1); |
---|
28 | mepdf A2(f2); |
---|
29 | A ( 0 ) =&A1; |
---|
30 | A ( 1 ) =&A2; |
---|
31 | |
---|
32 | int Npoints=100; |
---|
33 | mat x_grid(1,Npoints); |
---|
34 | x_grid.set_row(0,linspace ( -2.0, 4.0, Npoints )); |
---|
35 | mat y_grid(1,Npoints); |
---|
36 | y_grid.set_row(0,linspace ( -2.0, 4.0, Npoints )); |
---|
37 | |
---|
38 | mat Grid (2,Npoints*Npoints); |
---|
39 | Grid.set_submatrix ( 0,0, kron(x_grid,ones(1,Npoints)) ); |
---|
40 | Grid.set_submatrix ( 1,0, kron(ones(1,Npoints), y_grid) ); |
---|
41 | |
---|
42 | merger M ( A ); |
---|
43 | enorm<fsqmat> g0(xy); |
---|
44 | g0.set_parameters(vec("1 1"),mat("1 0; 0 1")); |
---|
45 | |
---|
46 | M.set_parameters(1.2,100,1); |
---|
47 | M.merge(&g0); |
---|
48 | |
---|
49 | MixEF &MM = M._Mix(); |
---|
50 | epdf* MP = MM.predictor(xy); |
---|
51 | |
---|
52 | vec Res1 = M.evalpdflog_m(Grid); |
---|
53 | mat Res2 = ((emix*)MP)->evalpdflog_M(Grid); |
---|
54 | |
---|
55 | it_file it("merger_iter_test.it"); |
---|
56 | it << Name("Npoints") << Npoints; |
---|
57 | it << Name("Grid") << Grid; |
---|
58 | it << Name("Res1") << Res1; |
---|
59 | it << Name("Res2") << Res2; |
---|
60 | } |
---|