Changeset 1349 for applications

Show
Ignore:
Timestamp:
05/03/11 18:10:42 (13 years ago)
Author:
sindj
Message:

Oprava dalsich drobnych chyb (pridavani otcovske podminky do totalne neutralnich poly). Jeste nejake zbyva odstranit. JS

Location:
applications/robust
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/main.cpp

    r1346 r1349  
    1818 
    1919const int emlig_size = 2; 
    20 const int utility_constant = 3; 
     20const int utility_constant = 10; 
    2121 
    2222 
     
    139139        vector<vector<string>> strings; 
    140140 
    141         char* file_strings[3] = {"c:\\Users\\Hontik\\Desktop\\dataGCClosePercDiff","c:\\ar_student_single","c:\\ar_cauchy_single"}; 
     141        char* file_strings[3] = {"c:\\dataCDClosePercDiff","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(2,30,false); 
     173                RARX* my_rarx = new RARX(2,10,false); 
    174174                 
    175175                 
    176176                mat V0 = 0.0001 * eye ( 3 ); 
    177                 ARX* my_arx = new ARX(0.97); 
     177                ARX* my_arx = new ARX(0.85); 
    178178                my_arx->set_statistics ( 1, V0 ); //nu is default (set to have finite moments) 
    179179                my_arx->set_constant ( false ); 
     
    200200                                conditions[k-3].ins(0,strings[j][k]); 
    201201 
    202                                 cout << "Condition:" << conditions[k-3] << endl; 
     202                                // cout << "Condition:" << conditions[k-3] << endl; 
    203203 
    204204                                my_rarx->bayes(conditions[k-3]); 
     
    284284                                        */ 
    285285 
    286                                         cout << "Coefficients: " << poly_coefs << endl; 
     286                                        //cout << "Coefficients: " << poly_coefs << endl; 
    287287                                                                                 
    288288                                        /* 
  • applications/robust/robustlib.cpp

    r1338 r1349  
    275275                                simplex->insert_gamma(0,bracket*multiplier,a_0-(*as_ref).first);                                                                 
    276276 
    277                                 bracket *= fact(sigma_order); 
     277                                // bracket *= fact(sigma_order); 
    278278 
    279279                                for(int k = 0;k < as1_order-1;k++) 
     
    299299 
    300300                                        simplex->insert_gamma(k+1,local_bracket*multiplier,a_0-(*as_ref).first); 
    301                                          
    302                                         bracket += local_bracket*fact(sigma_order-k); 
     301 
     302                                        int division_factor = 1; 
     303                                        for(int s = 0;s<k;s++) 
     304                                        { 
     305                                                division_factor *= k-s; 
     306                                        } 
     307                                         
     308                                        bracket += local_bracket/division_factor; //local_bracket*fact(sigma_order-k); 
    303309                                }                                
    304310 
     
    311317                        simplex->insert_gamma(0,correction_term_base,a_0);                       
    312318 
    313                         correction_term = fact(sigma_order)*correction_term_base; 
     319                        correction_term = correction_term_base;//fact(sigma_order)*correction_term_base; 
    314320 
    315321                        //cout << c << int_value << endl; 
  • applications/robust/robustlib.h

    r1346 r1349  
    2222using namespace itpp; 
    2323 
    24 const double max_range = 10;//numeric_limits<double>::max()/10e-10; 
     24const double max_range = 50;//numeric_limits<double>::max()/10e-10; 
    2525 
    2626/// An enumeration of possible actions performed on the polyhedrons. We can merge them or split them. 
     
    434434        }; 
    435435 
     436        ~c_statistic() 
     437        { 
     438                delete end_poly; 
     439                delete start_poly; 
     440        } 
     441 
    436442        void append_polyhedron(int row, polyhedron* appended_start, polyhedron* appended_end) 
    437443        { 
     
    732738        double normalization_factor; 
    733739 
     740        int condition_order; 
     741 
    734742         
    735743 
     
    948956                                                        else 
    949957                                                        { 
    950                                                                 current_parent->raise_multiplicity();                                                            
     958                                                                current_parent->raise_multiplicity(); 
     959                                                                current_parent->totally_neutral = true; 
     960                                                                current_parent->parentconditions.insert(toadd); 
    951961                                                        } 
    952962 
     
    10131023        double min_ll; 
    10141024 
     1025        double log_nc; 
     1026 
    10151027        vector<multiset<my_ivec>> correction_factors; 
    10161028 
     
    10261038 
    10271039                min_ll = numeric_limits<double>::max(); 
     1040 
     1041                condition_order = 0; 
    10281042        } 
    10291043 
    10301044        /// A constructor for creating an emlig when the user wants to create the statistic by himself. The creation of a 
    10311045        /// statistic is needed outside the constructor. Used for a user defined prior distribution on the parameters. 
    1032         emlig(c_statistic statistic) 
     1046        emlig(c_statistic statistic, int condition_order) 
    10331047        { 
    10341048                this->statistic = statistic;     
    10351049 
    10361050                min_ll = numeric_limits<double>::max(); 
    1037         } 
     1051 
     1052                this->condition_order = condition_order; 
     1053        } 
     1054 
    10381055 
    10391056        void step_me(int marker) 
     
    10571074                                */ 
    10581075 
    1059                                 cout << "Stepped." << endl; 
     1076                                // cout << "Stepped." << endl; 
     1077 
     1078                                for(set<simplex*>::iterator sim_ref = (*horiz_ref).triangulation.begin();sim_ref!=(*horiz_ref).triangulation.end();sim_ref++) 
     1079                                { 
     1080                                        if((*sim_ref)->vertices.size()!=i+1) 
     1081                                        { 
     1082                                                cout << "Something is wrong." << endl; 
     1083                                        } 
     1084                                } 
    10601085                                 
    10611086                                /* 
     
    11651190                bool should_remove = (toremove.size() != 0); 
    11661191                bool should_add    = (toadd.size() != 0); 
     1192 
     1193                if(should_remove) 
     1194                { 
     1195                        condition_order--; 
     1196                } 
     1197 
     1198                if(should_add) 
     1199                { 
     1200                        condition_order++; 
     1201                } 
    11671202 
    11681203                for_splitting.clear(); 
     
    12501285                                        local_condition = appended_coords*toadd; 
    12511286 
     1287                                        cout << "Vertex multiplicity: "<< current_vertex->get_multiplicity() << endl; 
     1288 
    12521289                                        current_vertex->set_state(local_condition,SPLIT); 
    12531290 
     
    12551292                                        if(local_condition == 0) 
    12561293                                        { 
     1294                                                cout << "Condition to add: " << toadd << endl; 
     1295                                                cout << "Vertex coords: " << appended_coords << endl; 
     1296 
    12571297                                                current_vertex->totally_neutral = true; 
    12581298 
    12591299                                                current_vertex->raise_multiplicity(); 
     1300                                                current_vertex->parentconditions.insert(condition_to_add); 
    12601301 
    12611302                                                current_vertex->negativeneutralvertices.insert(current_vertex); 
     
    12981339                } 
    12991340 
    1300                  
     1341                //step_me(1); 
    13011342                 
    13021343                if(should_remove) 
     
    13261367                                        if((*merge_ref)->get_multiplicity()>1) 
    13271368                                        { 
     1369                                                (*merge_ref)->parentconditions.erase(condition_to_remove); 
     1370 
    13281371                                                if(k==1) 
    13291372                                                { 
     
    15751618                } 
    15761619                 
    1577                 /* 
     1620                 
    15781621                vector<int> sizevector; 
    15791622                for(int s = 0;s<statistic.size();s++) 
     
    15811624                        sizevector.push_back(statistic.row_size(s)); 
    15821625                        cout << statistic.row_size(s) << ", "; 
    1583                 }*/ 
     1626                } 
    15841627                 
    15851628 
    1586                 //cout << endl; 
    1587  
    1588                 // this->step_me(2); 
     1629                cout << endl; 
     1630 
     1631                if(this->statistic.row_size(2)==62) 
     1632                { 
     1633                        this->step_me(2); 
     1634                } 
    15891635 
    15901636                if(should_add) 
     
    17431789                } 
    17441790 
     1791                /* 
    17451792                vector<int> sizevector; 
    17461793                //sizevector.clear(); 
     
    17521799                 
    17531800                cout << endl; 
    1754                  
     1801                */ 
     1802 
     1803                cout << "Normalization factor: " << normalization_factor << endl;        
     1804 
     1805                log_nc = log(normalization_factor) + logfact(condition_order-number_of_parameters-2); 
    17551806 
    17561807                /* 
     
    23082359        } 
    23092360 
     2361        int logfact(int factor) 
     2362        { 
     2363                if(factor>0) 
     2364                { 
     2365                        return factor+logfact(factor-1); 
     2366                } 
     2367                else 
     2368                { 
     2369                        return 0; 
     2370                } 
     2371        } 
    23102372protected: 
    23112373 
     
    26602722                        posterior->add_condition(yt); 
    26612723                } 
     2724 
     2725                 
    26622726                                 
    26632727        }