Changeset 1349 for applications
- Timestamp:
- 05/03/11 18:10:42 (14 years ago)
- Location:
- applications/robust
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/main.cpp
r1346 r1349 18 18 19 19 const int emlig_size = 2; 20 const int utility_constant = 3;20 const int utility_constant = 10; 21 21 22 22 … … 139 139 vector<vector<string>> strings; 140 140 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"}; 142 142 143 143 for(int i = 0;i<3;i++) … … 171 171 vector<vec> conditions; 172 172 //emlig* emliga = new emlig(2); 173 RARX* my_rarx = new RARX(2, 30,false);173 RARX* my_rarx = new RARX(2,10,false); 174 174 175 175 176 176 mat V0 = 0.0001 * eye ( 3 ); 177 ARX* my_arx = new ARX(0. 97);177 ARX* my_arx = new ARX(0.85); 178 178 my_arx->set_statistics ( 1, V0 ); //nu is default (set to have finite moments) 179 179 my_arx->set_constant ( false ); … … 200 200 conditions[k-3].ins(0,strings[j][k]); 201 201 202 cout << "Condition:" << conditions[k-3] << endl;202 // cout << "Condition:" << conditions[k-3] << endl; 203 203 204 204 my_rarx->bayes(conditions[k-3]); … … 284 284 */ 285 285 286 cout << "Coefficients: " << poly_coefs << endl;286 //cout << "Coefficients: " << poly_coefs << endl; 287 287 288 288 /* -
applications/robust/robustlib.cpp
r1338 r1349 275 275 simplex->insert_gamma(0,bracket*multiplier,a_0-(*as_ref).first); 276 276 277 bracket *= fact(sigma_order);277 // bracket *= fact(sigma_order); 278 278 279 279 for(int k = 0;k < as1_order-1;k++) … … 299 299 300 300 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); 303 309 } 304 310 … … 311 317 simplex->insert_gamma(0,correction_term_base,a_0); 312 318 313 correction_term = fact(sigma_order)*correction_term_base;319 correction_term = correction_term_base;//fact(sigma_order)*correction_term_base; 314 320 315 321 //cout << c << int_value << endl; -
applications/robust/robustlib.h
r1346 r1349 22 22 using namespace itpp; 23 23 24 const double max_range = 10;//numeric_limits<double>::max()/10e-10;24 const double max_range = 50;//numeric_limits<double>::max()/10e-10; 25 25 26 26 /// An enumeration of possible actions performed on the polyhedrons. We can merge them or split them. … … 434 434 }; 435 435 436 ~c_statistic() 437 { 438 delete end_poly; 439 delete start_poly; 440 } 441 436 442 void append_polyhedron(int row, polyhedron* appended_start, polyhedron* appended_end) 437 443 { … … 732 738 double normalization_factor; 733 739 740 int condition_order; 741 734 742 735 743 … … 948 956 else 949 957 { 950 current_parent->raise_multiplicity(); 958 current_parent->raise_multiplicity(); 959 current_parent->totally_neutral = true; 960 current_parent->parentconditions.insert(toadd); 951 961 } 952 962 … … 1013 1023 double min_ll; 1014 1024 1025 double log_nc; 1026 1015 1027 vector<multiset<my_ivec>> correction_factors; 1016 1028 … … 1026 1038 1027 1039 min_ll = numeric_limits<double>::max(); 1040 1041 condition_order = 0; 1028 1042 } 1029 1043 1030 1044 /// A constructor for creating an emlig when the user wants to create the statistic by himself. The creation of a 1031 1045 /// 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) 1033 1047 { 1034 1048 this->statistic = statistic; 1035 1049 1036 1050 min_ll = numeric_limits<double>::max(); 1037 } 1051 1052 this->condition_order = condition_order; 1053 } 1054 1038 1055 1039 1056 void step_me(int marker) … … 1057 1074 */ 1058 1075 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 } 1060 1085 1061 1086 /* … … 1165 1190 bool should_remove = (toremove.size() != 0); 1166 1191 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 } 1167 1202 1168 1203 for_splitting.clear(); … … 1250 1285 local_condition = appended_coords*toadd; 1251 1286 1287 cout << "Vertex multiplicity: "<< current_vertex->get_multiplicity() << endl; 1288 1252 1289 current_vertex->set_state(local_condition,SPLIT); 1253 1290 … … 1255 1292 if(local_condition == 0) 1256 1293 { 1294 cout << "Condition to add: " << toadd << endl; 1295 cout << "Vertex coords: " << appended_coords << endl; 1296 1257 1297 current_vertex->totally_neutral = true; 1258 1298 1259 1299 current_vertex->raise_multiplicity(); 1300 current_vertex->parentconditions.insert(condition_to_add); 1260 1301 1261 1302 current_vertex->negativeneutralvertices.insert(current_vertex); … … 1298 1339 } 1299 1340 1300 1341 //step_me(1); 1301 1342 1302 1343 if(should_remove) … … 1326 1367 if((*merge_ref)->get_multiplicity()>1) 1327 1368 { 1369 (*merge_ref)->parentconditions.erase(condition_to_remove); 1370 1328 1371 if(k==1) 1329 1372 { … … 1575 1618 } 1576 1619 1577 /*1620 1578 1621 vector<int> sizevector; 1579 1622 for(int s = 0;s<statistic.size();s++) … … 1581 1624 sizevector.push_back(statistic.row_size(s)); 1582 1625 cout << statistic.row_size(s) << ", "; 1583 } */1626 } 1584 1627 1585 1628 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 } 1589 1635 1590 1636 if(should_add) … … 1743 1789 } 1744 1790 1791 /* 1745 1792 vector<int> sizevector; 1746 1793 //sizevector.clear(); … … 1752 1799 1753 1800 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); 1755 1806 1756 1807 /* … … 2308 2359 } 2309 2360 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 } 2310 2372 protected: 2311 2373 … … 2660 2722 posterior->add_condition(yt); 2661 2723 } 2724 2725 2662 2726 2663 2727 }