root/library/tests/merger_2d_test.cpp @ 675

Revision 675, 1.6 kB (checked in by mido, 15 years ago)

experiment: epdf as a descendat of mpdf

  • Property svn:eol-style set to native
Line 
1
2#include "stat/exp_family.h"
3#include "stat/merger.h"
4
5using namespace bdm;
6
7using namespace bdm;
8
9//These lines are needed for use of cout and endl
10using std::cout;
11using std::endl;
12
13int main() {
14
15        RNG_randomize();
16
17        RV x ( "{x }", "1" );
18        RV y ( "{y }", "1" );
19
20        RV xy = x;
21        xy.add ( y );
22
23        enorm_fsqmat_ptr f1;
24        f1->set_rv ( xy );
25        enorm_fsqmat_ptr f2;
26        f2->set_rv ( xy );
27
28        mat R1 ( "0.5 0.48; 0.48 0.5" );
29        mat R2 ( "0.5 0; 0 0.1" );
30        f1->set_parameters ( "1 1", R1 );
31        f2->set_parameters ( "1 1", mat ( "0.5 0; 0 0.1" ) );
32
33        mpdf_array A ( 2 );
34        A ( 0 ) = f1;
35        A ( 1 ) = f2;
36
37        int Npoints = 100;
38        mat x_grid ( 1, Npoints );
39        x_grid.set_row ( 0, linspace ( -2.0, 4.0, Npoints ) );
40        mat y_grid ( 1, Npoints );
41        y_grid.set_row ( 0, linspace ( -2.0, 4.0, Npoints ) );
42
43        mat Grid ( 2, Npoints*Npoints );
44        Grid.set_submatrix ( 0, 0, kron ( x_grid, ones ( 1, Npoints ) ) );
45        Grid.set_submatrix ( 1, 0, kron ( ones ( 1, Npoints ), y_grid ) );
46
47        merger_mix M ( A );
48        enorm<fsqmat> g0;
49        g0.set_rv ( xy );
50        g0.set_parameters ( vec ( "1 1" ), mat ( "10 0; 0 10" ) );
51
52        M.set_parameters ( 1 );
53        M.set_method ( LOGNORMAL, 1e8 );
54        M.set_support ( g0, 400 );
55        M.merge();
56
57        MixEF &MM = M._Mix();
58        emix* MP = MM.epredictor(); //xy
59
60        vec Res1 = M.evallog_m ( Grid );
61        mat Res2 = ( MP )->evallog_M ( Grid );
62
63        it_file it ( "merger_2d_test.it" );
64        it << Name ( "Npoints" ) << Npoints;
65        it << Name ( "Grid" ) << Grid;
66        it << Name ( "Res1" ) << Res1;
67        it << Name ( "Res2" ) << Res2;
68        it << Name ( "S1" ) << f1->evallog_m ( Grid );
69        it << Name ( "S2" ) << f2->evallog_m ( Grid );
70        cout << ( ( enorm<ldmat>* ) ( MP->_Coms ( 0 ).get() ) )->_R().to_mat() << endl;
71}
Note: See TracBrowser for help on using the browser.