root/library/tests/stresssuite/merger_iter_stress.cpp @ 741

Revision 741, 1.7 kB (checked in by smidl, 14 years ago)

Stress tests are passing now. Missing validate calls are filled...

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