[262] | 1 | |
---|
[386] | 2 | #include "stat/exp_family.h" |
---|
| 3 | #include "stat/merger.h" |
---|
[188] | 4 | |
---|
[254] | 5 | using namespace bdm; |
---|
[188] | 6 | |
---|
[386] | 7 | using namespace bdm; |
---|
| 8 | |
---|
[188] | 9 | //These lines are needed for use of cout and endl |
---|
| 10 | using std::cout; |
---|
| 11 | using std::endl; |
---|
| 12 | |
---|
| 13 | int main() { |
---|
| 14 | |
---|
[198] | 15 | RNG_randomize(); |
---|
[188] | 16 | |
---|
[477] | 17 | RV x ( "{x }", "1" ); |
---|
| 18 | RV y ( "{y }", "1" ); |
---|
| 19 | |
---|
| 20 | RV xy = x; |
---|
| 21 | xy.add ( y ); |
---|
| 22 | |
---|
[529] | 23 | enorm_fsqmat_ptr f1; |
---|
[507] | 24 | f1->set_rv ( xy ); |
---|
[529] | 25 | enorm_fsqmat_ptr f2; |
---|
[507] | 26 | f2->set_rv ( xy ); |
---|
[529] | 27 | enorm_fsqmat_ptr f3; |
---|
[507] | 28 | f3->set_rv ( y ); |
---|
[477] | 29 | |
---|
[507] | 30 | f1->set_parameters ( "4 3", mat ( "0.4 0.3; 0.3 0.4" ) ); |
---|
| 31 | f2->set_parameters ( "1 3", mat ( "0.3 -0.2; -0.2 0.3" ) ); |
---|
| 32 | f3->set_parameters ( "2", mat ( "0.4" ) ); |
---|
[477] | 33 | |
---|
[693] | 34 | pdf_array A ( 3 ); |
---|
[675] | 35 | A ( 0 ) = f1; |
---|
| 36 | A ( 1 ) = f2; |
---|
| 37 | A ( 2 ) = f3; |
---|
[477] | 38 | |
---|
| 39 | int Npoints = 100; |
---|
| 40 | mat x_grid ( 1, Npoints ); |
---|
| 41 | x_grid.set_row ( 0, linspace ( -2.0, 4.0, Npoints ) ); |
---|
| 42 | mat y_grid ( 1, Npoints ); |
---|
| 43 | y_grid.set_row ( 0, linspace ( -2.0, 4.0, Npoints ) ); |
---|
| 44 | |
---|
| 45 | mat Grid ( 2, Npoints*Npoints ); |
---|
| 46 | Grid.set_submatrix ( 0, 0, kron ( x_grid, ones ( 1, Npoints ) ) ); |
---|
| 47 | Grid.set_submatrix ( 1, 0, kron ( ones ( 1, Npoints ), y_grid ) ); |
---|
| 48 | |
---|
[386] | 49 | merger_mix M ( A ); |
---|
[477] | 50 | enorm<fsqmat> g0; |
---|
| 51 | g0.set_rv ( xy ); |
---|
| 52 | g0.set_parameters ( vec ( "4 4" ), mat ( "1 0; 0 1" ) ); |
---|
| 53 | |
---|
| 54 | M.set_parameters ( 5 ); |
---|
| 55 | M.set_method ( LOGNORMAL, 1.2 ); |
---|
| 56 | M.set_support ( g0, 400 ); |
---|
[386] | 57 | M.merge(); |
---|
[477] | 58 | |
---|
[188] | 59 | MixEF &MM = M._Mix(); |
---|
[270] | 60 | epdf* MP = MM.epredictor();//xy |
---|
[477] | 61 | |
---|
| 62 | vec Res1 = M.evallog_m ( Grid ); |
---|
| 63 | mat Res2 = ( ( emix* ) MP )->evallog_M ( Grid ); |
---|
| 64 | |
---|
| 65 | it_file it ( "merger_iter_test.it" ); |
---|
| 66 | it << Name ( "Npoints" ) << Npoints; |
---|
| 67 | it << Name ( "Grid" ) << Grid; |
---|
| 68 | it << Name ( "Res1" ) << Res1; |
---|
| 69 | it << Name ( "Res2" ) << Res2; |
---|
[188] | 70 | } |
---|