Show
Ignore:
Timestamp:
05/02/11 11:27:15 (13 years ago)
Author:
sindj
Message:

Oprava integrace, pokud se merguje i splituje. JS

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/main.cpp

    r1343 r1346  
    1818 
    1919const int emlig_size = 2; 
    20 const int utility_constant = 2; 
     20const int utility_constant = 3; 
    2121 
    2222 
     
    139139        vector<vector<string>> strings; 
    140140 
    141         char* file_strings[3] = {"c:\\dataADClosePercDiff","c:\\ar_student_single","c:\\ar_cauchy_single"}; 
     141        char* file_strings[3] = {"c:\\Users\\Hontik\\Desktop\\dataGCClosePercDiff","c:\\ar_student_single","c:\\ar_cauchy_single"}; 
    142142 
    143143        for(int i = 0;i<3;i++) 
     
    171171                vector<vec> conditions; 
    172172                //emlig* emliga = new emlig(2); 
    173                 RARX* my_rarx = new RARX(3,30,true); 
     173                RARX* my_rarx = new RARX(2,30,false); 
    174174                 
    175175                 
     
    211211                                         
    212212                                 
    213                                 if(k>10) 
     213                                if(k>8) 
    214214                                { 
    215215                                        //my_rarx->posterior->step_me(0); 
    216216 
    217                                         mat samples = my_rarx->posterior->sample_mat(10); 
    218  
    219                                         pair<vec,mat> imp_samples = my_rarx->posterior->importance_sample(20); 
    220  
    221                                         cout << imp_samples.first << endl; 
     217                                        //mat samples = my_rarx->posterior->sample_mat(10); 
     218 
     219                                        pair<vec,mat> imp_samples = my_rarx->posterior->importance_sample(1000); 
     220 
     221                                        //cout << imp_samples.first << endl; 
    222222                                         
    223223                                        vec sample_prediction; 
    224                                         for(int t = 0;t<samples.cols();t++) 
     224                                        for(int t = 0;t<imp_samples.first.size();t++) 
    225225                                        { 
    226226                                                vec lap_sample = conditions[k-3].left(2); 
    227                                                 lap_sample.ins(lap_sample.size(),1.0); 
     227                                                //lap_sample.ins(lap_sample.size(),1.0); 
    228228                                                 
    229229                                                lap_sample.ins(0,LapRNG()); 
    230230 
    231                                                 sample_prediction.ins(0,lap_sample*samples.get_col(t)); 
     231                                                sample_prediction.ins(0,lap_sample*imp_samples.second.get_col(t)); 
    232232                                        } 
    233233 
     
    237237                                        // cout << sample_prediction << endl; 
    238238                                        vec poly_coefs; 
     239                                        double prediction; 
    239240                                        bool stop_iteration = false; 
    240241                                        int en = 1; 
    241242                                        do 
    242243                                        { 
    243                                                 double poly_coef = ones(sample_pow.size())*sample_pow/sample_pow.size(); 
     244                                                double poly_coef = imp_samples.first*sample_pow/(imp_samples.first*ones(imp_samples.first.size())); 
     245 
     246                                                if(en==1) 
     247                                                { 
     248                                                        prediction = poly_coef; 
     249                                                } 
    244250 
    245251                                                poly_coef = poly_coef*en*fact(utility_constant-2+en)/fact(utility_constant-2); 
     
    278284                                        */ 
    279285 
    280                                         // cout << "Coefficients: " << poly_coefs << endl; 
     286                                        cout << "Coefficients: " << poly_coefs << endl; 
    281287                                                                                 
    282288                                        /* 
     
    287293                                        */ 
    288294                                         
     295 
     296 
    289297                                        cvec actions = roots(poly_coefs); 
    290298                                         
     
    295303                                                if(actions[t].imag() == 0) 
    296304                                                { 
    297                                                          
    298  
    299305                                                        double second_derivative = 0; 
    300306                                                        for(int q = 1;q<poly_coefs.size();q++) 
     
    319325                                        // cout << "MaxLik coords:" << my_rarx->posterior->minimal_vertex->get_coordinates() << endl; 
    320326 
     327                                        /* 
    321328                                        double prediction = 0; 
    322329                                        for(int s = 1;s<samples.rows();s++) 
    323330                                        { 
    324331                                                 
    325                                                 double avg_parameter = samples.get_row(s)*ones(samples.cols())/samples.cols(); 
     332                                                double avg_parameter = imp_samples.get_row(s)*ones(samples.cols())/samples.cols(); 
    326333 
    327334                                                prediction += avg_parameter*conditions[k-3][s-1]; 
     
    355362                                                myfile.close(); 
    356363                                                */ 
    357                                         } 
    358  
    359                                         cout << "Prediction: "<< prediction << endl; 
     364 
     365                                         
     366                                        //} 
     367 
     368                                        // cout << "Prediction: "<< prediction << endl; 
    360369                                         
    361370                                        enorm<ldmat>* pred_mat = my_arx->epredictor(conditions[k-3].left(2)); 
     
    401410                                        } 
    402411                                        myfile.close(); 
    403                                          
     412                                        //*/ 
    404413 
    405414                                }