Show
Ignore:
Timestamp:
04/20/11 20:11:40 (13 years ago)
Author:
sindj
Message:

Sampling dokoncen, zbyva logaritmovat normalizacni faktor a testovat. JS

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/main.cpp

    r1331 r1336  
    134134        vector<vector<string>> strings; 
    135135 
    136         char* file_strings[3] = {"c:\\ar_cauchy_single.txt", "c:\\ar_normal_single.txt","c:\\ar_student_single.txt"}; 
     136        char* file_strings[3] = {"c:\\ar_student_single.txt", "c:\\ar_student_single.txt","c:\\ar_cauchy_single.txt"}; 
    137137 
    138138        for(int i = 0;i<3;i++) 
     
    162162                vector<vec> conditions; 
    163163                //emlig* emliga = new emlig(2); 
    164                 RARX* my_rarx = new RARX(2,70); 
     164                RARX* my_rarx = new RARX(3,20,true); 
    165165 
    166166                for(int k = 1;k<170;k++) 
     
    189189                                         
    190190                                 
    191                                 if(k>5) 
     191                                if(k>10) 
    192192                                { 
    193193                                        //my_rarx->posterior->step_me(0); 
    194194 
    195                                         my_rarx->posterior->sample_mat(1); 
    196  
     195                                        mat samples = my_rarx->posterior->sample_mat(50); 
     196                                         
     197                                         
    197198                                        cout << "MaxLik coords:" << my_rarx->posterior->minimal_vertex->get_coordinates() << endl; 
    198199 
    199                                         ofstream myfile; 
    200                                         char fstring[80]; 
    201                                         strcpy(fstring,file_strings[j]); 
    202                                         strcat(fstring,"_res.txt"); 
    203  
    204                                         myfile.open(fstring,ios::app); 
    205                                         myfile << my_rarx->posterior->minimal_vertex->get_coordinates()[0]; 
    206                                         if(k!=strings[j].size()-1) 
     200                                        for(int s = 0;s<samples.rows();s++) 
    207201                                        { 
    208                                                 myfile << ","; 
     202                                                 
     203                                                double avg_parameter = samples.get_row(s)*ones(samples.cols())/samples.cols();                                           
     204                                                 
     205                                                ofstream myfile; 
     206                                                char fstring[80]; 
     207                                                strcpy(fstring,file_strings[j]); 
     208 
     209                                                char es[5]; 
     210                                                strcat(fstring,itoa(s,es,10)); 
     211 
     212                                                strcat(fstring,"_res.txt"); 
     213                                                 
     214 
     215                                                myfile.open(fstring,ios::app); 
     216                                                 
     217                                                //myfile << my_rarx->posterior->minimal_vertex->get_coordinates()[0]; 
     218                                                myfile << avg_parameter; 
     219                                                 
     220                                                if(k!=strings[j].size()-1) 
     221                                                { 
     222                                                        myfile << ","; 
     223                                                } 
     224                                                else 
     225                                                { 
     226                                                        myfile << endl; 
     227                                                } 
     228                                                myfile.close(); 
    209229                                        } 
    210                                         else 
    211                                         { 
    212                                                 myfile << endl; 
    213                                         } 
    214                                         myfile.close(); 
    215230                                }                                        
    216231                        }