[262] | 1 | |
---|
[384] | 2 | #include "stat/exp_family.h" |
---|
| 3 | #include "stat/merger.h" |
---|
[188] | 4 | |
---|
[254] | 5 | using namespace bdm; |
---|
[188] | 6 | |
---|
[384] | 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(); |
---|
[190] | 16 | |
---|
[188] | 17 | RV x ( "{x }","1" ); |
---|
| 18 | RV y ( "{y }","1" ); |
---|
| 19 | |
---|
| 20 | RV xy=x; xy.add(y); |
---|
| 21 | |
---|
[270] | 22 | enorm<fsqmat> f1;f1.set_rv ( xy ); |
---|
| 23 | enorm<fsqmat> f2;f2.set_rv ( xy ); |
---|
| 24 | enorm<fsqmat> f3;f3.set_rv(y); |
---|
[190] | 25 | |
---|
[198] | 26 | f1.set_parameters ( "4 3",mat ( "0.4 0.3; 0.3 0.4" ) ); |
---|
| 27 | f2.set_parameters ( "1 3",mat ( "0.3 -0.2; -0.2 0.3" ) ); |
---|
| 28 | f3.set_parameters ( "2",mat("0.4") ); |
---|
[188] | 29 | |
---|
[198] | 30 | Array<mpdf* > A ( 3 ); |
---|
[203] | 31 | mepdf A1(&f1); |
---|
| 32 | mepdf A2(&f2); |
---|
| 33 | mepdf A3(&f3); |
---|
[190] | 34 | A ( 0 ) =&A1; |
---|
| 35 | A ( 1 ) =&A2; |
---|
[198] | 36 | A ( 2 ) =&A3; |
---|
[188] | 37 | |
---|
| 38 | int Npoints=100; |
---|
| 39 | mat x_grid(1,Npoints); |
---|
| 40 | x_grid.set_row(0,linspace ( -2.0, 4.0, Npoints )); |
---|
| 41 | mat y_grid(1,Npoints); |
---|
| 42 | y_grid.set_row(0,linspace ( -2.0, 4.0, Npoints )); |
---|
| 43 | |
---|
| 44 | mat Grid (2,Npoints*Npoints); |
---|
| 45 | Grid.set_submatrix ( 0,0, kron(x_grid,ones(1,Npoints)) ); |
---|
| 46 | Grid.set_submatrix ( 1,0, kron(ones(1,Npoints), y_grid) ); |
---|
| 47 | |
---|
[384] | 48 | merger_mix M ( A ); |
---|
[270] | 49 | enorm<fsqmat> g0; g0.set_rv(xy); |
---|
[198] | 50 | g0.set_parameters(vec("4 4"),mat("1 0; 0 1")); |
---|
[188] | 51 | |
---|
[384] | 52 | M.set_parameters(5); |
---|
| 53 | M.set_method(LOGNORMAL,1.2); |
---|
| 54 | M.set_support(g0,400); |
---|
| 55 | M.merge(); |
---|
[188] | 56 | |
---|
| 57 | MixEF &MM = M._Mix(); |
---|
[270] | 58 | epdf* MP = MM.epredictor();//xy |
---|
[188] | 59 | |
---|
[211] | 60 | vec Res1 = M.evallog_m(Grid); |
---|
| 61 | mat Res2 = ((emix*)MP)->evallog_M(Grid); |
---|
[188] | 62 | |
---|
| 63 | it_file it("merger_iter_test.it"); |
---|
| 64 | it << Name("Npoints") << Npoints; |
---|
| 65 | it << Name("Grid") << Grid; |
---|
| 66 | it << Name("Res1") << Res1; |
---|
| 67 | it << Name("Res2") << Res2; |
---|
| 68 | } |
---|