Changeset 301 for mpdm/TR2244

Show
Ignore:
Timestamp:
03/19/09 15:39:00 (16 years ago)
Author:
smidl
Message:

TR merging 2D example

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • mpdm/TR2244/merger_iter_cond.cpp

    r299 r301  
    1515        RV y ( "{y }","1" ); 
    1616        RV u1 ( "{u1 }","1" ); 
    17         RV u2 ( "{u2 }","1" ); 
     17//      RV u2 ( "{u2 }","1" ); 
    1818 
    1919        RV all = y; 
    2020        all.add ( u1 ); 
    21         all.add ( u2 ); 
     21//      all.add ( u2 ); 
    2222 
    2323        mlnorm<fsqmat> f1; f1.set_rv( y ); f1.set_rvc( u1 ); 
    24         mlnorm<fsqmat> f2; f2.set_rv( y ); f2.set_rvc( u2 ); 
     24        enorm<fsqmat>  f2; f2.set_rv( y );// f2.set_rvc( u2 ); 
    2525 
    2626        //Differneces in constant term are essential 
    2727        f1.set_parameters ( "0.4","1",mat ( "0.04" ) ); 
    28         f2.set_parameters ( "0.2","-1",mat ( "0.08" ) ); 
     28        f2.set_parameters ( "0.2", mat ( "0.08" ) ); 
    2929 
     30        mepdf mf2(&f2); 
     31         
    3032        Array<mpdf* > A ( 2 ); 
    3133        A ( 0 ) =&f1; 
    32         A ( 1 ) =&f2; 
     34        A ( 1 ) =&mf2; 
    3335 
    3436        merger M ( A ); 
    3537        M.debug_file("iter_cond_debug.it"); 
    3638        enorm<ldmat> g0; g0.set_rv ( all ); 
    37         mat Cov=0.3*eye ( 3 ); 
    38         Cov(1,2)=0.29; 
    39         Cov(2,1)=0.29; 
    40         g0.set_parameters ( vec ( "1 1 1" ),Cov);// +1*ones ( 3,3 ) ); 
     39        mat Cov=10*eye ( 2 ); 
     40/*      Cov(1,2)=0.29; 
     41        Cov(2,1)=0.29;*/ 
     42        g0.set_parameters ( vec ( "0 0" ),Cov);// +1*ones ( 3,3 ) ); 
    4143 
    42         enorm<ldmat>* teste=g0.marginal(concat(u1,u2)); 
    43         mlnorm<ldmat>* testm=(mlnorm<ldmat>*)teste->condition(u2); 
     44//      enorm<ldmat>* teste=g0.marginal(concat(u1,u2)); 
     45//      mlnorm<ldmat>* testm=(mlnorm<ldmat>*)teste->condition(u2); 
    4446         
    45         M.set_parameters ( 1.2,1000,1 ); 
     47        M.set_parameters ( 1.2,1000,1); 
    4648         
    47         Array<vec> YUU(3);  
     49        Array<vec> YUU(2);  
    4850        YUU(0)=linspace(-2.9,3.1,20); 
    4951        YUU(1)=linspace(-5,5,20); 
    50         YUU(2)=linspace(-3,3,20); 
     52        //YUU(2)=linspace(-3,3,20); 
    5153 
    5254        M.set_grid(YUU); 
     
    5456        int Ntrials=1; 
    5557        vec A1s ( Ntrials ); 
    56         vec A2s ( Ntrials ); 
     58//      vec A2s ( Ntrials ); 
    5759        vec R1s ( Ntrials ); 
    5860        vec R2s ( Ntrials ); 
     
    6870 
    6971                RV yu1 = y; yu1.add ( u1 ); 
    70                 RV yu2 = y; yu2.add ( u2 ); 
     72//              RV yu2 = y; yu2.add ( u2 ); 
    7173                enorm<ldmat>* P1m= ( enorm<ldmat>* ) MP->marginal ( yu1 ); 
    72                 enorm<ldmat>* P2m= ( enorm<ldmat>* ) MP->marginal ( yu2 ); 
     74                enorm<ldmat>* P2m= ( enorm<ldmat>* ) MP->marginal ( y ); 
    7375                mlnorm<ldmat>* P1c= ( mlnorm<ldmat>* ) ( P1m->condition ( y ) ); 
    74                 mlnorm<ldmat>* P2c= ( mlnorm<ldmat>* ) ( P2m->condition ( y ) ); 
     76//              mlnorm<ldmat>* P2c= ( mlnorm<ldmat>* ) ( P2m->condition ( y ) ); 
    7577 
    7678                A1s(it) = P1c->_A()(0,0); 
    77                 A2s(it) = P2c->_A()(0,0); 
     79//              A2s(it) = P2c->_A()(0,0); 
    7880                R1s(it) = P1c->_R()(0,0); 
    79                 R2s(it) = P2c->_R()(0,0); 
     81                R2s(it) = P2m->_R().to_mat()(0,0); 
    8082                C1s(it) = P1c->_mu_const()(0); 
    81                 C2s(it) = P2c->_mu_const()(0); 
     83                C2s(it) = P2m->_mu()(0); 
    8284 
    8385                cout << "mean: " << MM._Coms(0)->_e()->mean() <<endl; 
     
    8991        cout << "C2s:" <<C2s<<endl; 
    9092        double A1mean = sum(A1s)/Ntrials; 
    91         double A2mean = sum(A2s)/Ntrials; 
     93//      double A2mean = sum(A2s)/Ntrials; 
    9294        double C1mean = sum(C1s)/Ntrials; 
    9395        double C2mean = sum(C2s)/Ntrials; 
     
    9597        double R2mean = sum(R2s)/Ntrials; 
    9698        cout << "A1: " << A1mean << " +- " << 2*sqrt(sum_sqr(A1s)/Ntrials-A1mean*A1mean) <<endl; 
    97         cout << "A2: " << A2mean << " +- " << 2*sqrt(sum_sqr(A2s)/Ntrials-A2mean*A2mean) <<endl; 
     99//      cout << "A2: " << A2mean << " +- " << 2*sqrt(sum_sqr(A2s)/Ntrials-A2mean*A2mean) <<endl; 
    98100        cout << "C1: " << C1mean << " +- " << 2*sqrt(sum_sqr(C1s)/Ntrials-C1mean*C1mean) <<endl; 
    99101        cout << "C2: " << C2mean << " +- " << 2*sqrt(sum_sqr(C2s)/Ntrials-C2mean*C2mean) <<endl;