Changeset 1365 for applications/robust
- Timestamp:
- 05/10/11 13:10:46 (14 years ago)
- Location:
- applications/robust
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/main.cpp
r1362 r1365 48 48 HSZ hszItem = DdeCreateStringHandle(idInst, szItem, 0); 49 49 HDDEDATA hData = DdeClientTransaction(NULL,0,hConv,hszItem,CF_TEXT, 50 XTYP_ REQUEST,TIMEOUT_ASYNC , NULL);50 XTYP_ADVSTART,TIMEOUT_ASYNC , NULL); //TIMEOUT_ASYNC 51 51 if (hData==NULL) 52 52 { … … 112 112 { 113 113 V0 = 0.01 * eye(ar_components.size()+2); 114 V0(0,0) = 1;114 V0(0,0) = 0; 115 115 my_arx->set_constant(true); 116 116 … … 120 120 121 121 V0 = 0.01 * eye(ar_components.size()+1); 122 V0(0,0) = 1;122 V0(0,0) = 0; 123 123 my_arx->set_constant(false); 124 124 … … 207 207 /* 208 208 char szApp[] = "MT4"; 209 char szTopic[] = " ASK";210 char szItem1[] = "EUR USD";209 char szTopic[] = "BID"; 210 char szItem1[] = "EURJPY"; 211 211 212 212 //DDE Initialization … … 260 260 Sleep(300000); 261 261 Sleep(3000); 262 */262 263 263 264 264 /* … … 375 375 376 376 377 377 378 vector<vector<string>> strings; 378 379 … … 410 411 } 411 412 413 412 414 list<list<pair<int,int>>> model_types = model::possible_models_recurse(max_model_order,data_matrix.rows()); 413 415 414 416 list<model*> models; 415 417 for(list<list<pair<int,int>>>::iterator model_type = model_types.begin();model_type!=model_types.end();model_type++) … … 441 443 442 444 cout << "Updated." << endl; 443 445 444 446 /* 445 447 vector<vec> conditions; … … 652 654 */ 653 655 656 654 657 ofstream myfile; 655 658 char fstring[80]; … … 670 673 671 674 myfile.close(); 672 675 } 673 676 /* 674 677 myfile.open(f2string,ios::app); … … 706 709 707 710 708 }711 //} 709 712 710 713 -
applications/robust/robustlib.cpp
r1362 r1365 147 147 //cout << "Base coords: " << base_vertex->get_coordinates() << endl; 148 148 //cout << "Condition: " << as_toprow->condition_sum << endl; 149 //pause(10); 150 151 a_0 = base_vertex->get_coordinates()*cur_condition-as_toprow->condition_sum[0]; 152 153 149 //pause(0.1); 150 151 a_0 = -base_vertex->get_coordinates()*cur_condition+as_toprow->condition_sum[0]; 152 154 153 int row_count = 0; 155 154 for(set<vertex*>::iterator vert_ref = simplex->vertices.begin(); vert_ref!=simplex->vertices.end();vert_ref++) … … 230 229 cout << "a_" << as_count << ": " << (*as_ref).first << " "; 231 230 as_count++; 232 }*/ 231 } 232 */ 233 233 234 234 double int_value = 0; … … 269 269 multiplier /= (*as_ref).first; 270 270 number_of_factors += 1; 271 } 272 273 } 274 271 } 272 } 273 274 double gamma_multiplier = -(*as_ref).first-a_0; 275 276 double bracket = fact(as1_order-1)/pow(gamma_multiplier,sigma_order+1); 275 277 276 277 double bracket = fact(as1_order-1)/pow(a_0-(*as_ref).first,sigma_order+1); 278 279 simplex->insert_gamma(0,bracket*multiplier,a_0-(*as_ref).first); 280 281 // bracket *= fact(sigma_order); 278 simplex->insert_gamma(0,bracket*multiplier,gamma_multiplier); 279 280 // bracket *= fact(sigma_order); 282 281 283 282 for(int k = 0;k < as1_order-1;k++) 284 283 { 285 284 double local_bracket = 0; 286 double bracket_factor = -pow((double)-1,k+1)/fact(as1_order-1-k)/pow(a_0-(*as_ref).first,sigma_order-k);285 double bracket_factor = 1/fact(as1_order-1-k)/pow(gamma_multiplier,sigma_order-k);//pow((double)-1,k+1) 287 286 288 287 ivec control_vec = ivec(); … … 302 301 } 303 302 304 simplex->insert_gamma(k+1,local_bracket*multiplier, a_0-(*as_ref).first);303 simplex->insert_gamma(k+1,local_bracket*multiplier,gamma_multiplier); 305 304 306 305 int division_factor = 1; … … 314 313 315 314 int_value += multiplier*bracket; 315 316 316 317 317 318 } 318 319 319 double correction_term_base = correction_term/pow( a_0,sigma_order+1);320 321 simplex->insert_gamma(0,correction_term_base, a_0);320 double correction_term_base = correction_term/pow(-a_0,sigma_order+1); 321 322 simplex->insert_gamma(0,correction_term_base,-a_0); 322 323 323 324 correction_term = correction_term_base;//fact(sigma_order)*correction_term_base; … … 325 326 //cout << c << int_value << endl; 326 327 327 int_value += correction_term; 328 328 int_value += correction_term; 329 329 330 330 //cout << "Probability:" << int_value << endl; -
applications/robust/robustlib.h
r1362 r1365 1063 1063 /// A default constructor creates an emlig with predefined statistic representing only the range of the given 1064 1064 /// parametric space, where the number of parameters of the needed model is given as a parameter to the constructor. 1065 emlig(int number_of_parameters, bool is_proper,double soft_prior_parameter)1065 emlig(int number_of_parameters, double soft_prior_parameter) 1066 1066 { 1067 1067 this->number_of_parameters = number_of_parameters; 1068 1068 1069 1069 condition_order = number_of_parameters+2; 1070 1071 if(is_proper) 1072 condition_order++; 1073 1070 1074 1071 create_statistic(number_of_parameters, soft_prior_parameter); 1075 1072 … … 1078 1075 min_ll = numeric_limits<double>::max(); 1079 1076 1080 if(is_proper) 1081 { 1082 double normalization_factor = 0; 1083 int counter = 0; 1084 for(polyhedron* top_ref = statistic.rows[number_of_parameters];top_ref!=statistic.get_end();top_ref=top_ref->next_poly) 1085 { 1086 counter++; 1087 toprow* cur_toprow = (toprow*)top_ref; 1077 1078 double normalization_factor = 0; 1079 int counter = 0; 1080 for(polyhedron* top_ref = statistic.rows[number_of_parameters];top_ref!=statistic.get_end();top_ref=top_ref->next_poly) 1081 { 1082 counter++; 1083 toprow* cur_toprow = (toprow*)top_ref; 1088 1084 1089 1090 1091 1092 1093 log_nc = log(normalization_factor) + logfact(condition_order-number_of_parameters-2);1094 1095 1096 1097 1098 1099 1100 }1085 set<simplex*>::iterator cur_simplex = cur_toprow->triangulation.begin(); 1086 normalization_factor += cur_toprow->integrate_simplex(*cur_simplex,'X'); 1087 } 1088 1089 log_nc = log(normalization_factor) + logfact(condition_order-number_of_parameters-2)-(condition_order-number_of_parameters-2)*2; 1090 1091 /* 1092 cout << "part1: " << log(normalization_factor) << endl; 1093 cout << "part2: " << logfact(condition_order-number_of_parameters-2) << endl; 1094 pause(1); 1095 */ 1096 1101 1097 1102 1098 } … … 1884 1880 // cout << "Normalization factor: " << normalization_factor << endl; 1885 1881 1886 log_nc = log(normalization_factor) + logfact(condition_order-number_of_parameters-2) ;1887 1888 1882 log_nc = log(normalization_factor) + logfact(condition_order-number_of_parameters-2)-(condition_order-number_of_parameters-2)*2; 1883 1884 /* 1889 1885 cout << "part1: " << log(normalization_factor) << endl; 1890 1886 cout << "part2: " << logfact(condition_order-number_of_parameters-2) << endl; 1891 1887 pause(1); 1888 */ 1892 1889 1893 1890 … … 2608 2605 vec2.ins(0,soft_prior_parameter); 2609 2606 2610 vec1.ins(0, -1);2611 vec2.ins(0, -1);2612 } 2613 2614 cout << vec1 << endl;2615 cout << vec2 << endl;2607 vec1.ins(0,0); 2608 vec2.ins(0,0); 2609 } 2610 2611 // cout << vec1 << endl; 2612 // cout << vec2 << endl; 2616 2613 2617 2614 … … 2791 2788 this->has_constant = has_constant; 2792 2789 2793 posterior = new emlig(number_of_parameters, true,0.001);2790 posterior = new emlig(number_of_parameters,0.001); 2794 2791 2795 2792 this->window_size = window_size;