Changeset 1325
- Timestamp:
- 04/12/11 18:11:50 (14 years ago)
- Location:
- applications/robust
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/robustlib.cpp
r1324 r1325 97 97 98 98 emlig* current_emlig; 99 simplex->gamma_parameters.clear(); 100 simplex->gamma_sum = 0; 99 101 100 102 if(this->my_emlig!=NULL) … … 250 252 } 251 253 252 } 253 254 255 256 double bracket = fact(sigma_order)/fact(as1_order-1)/pow(a_0-(*as_ref).first,sigma_order+1); 254 } 255 256 257 258 double bracket = fact(as1_order-1)/pow(a_0-(*as_ref).first,sigma_order+1); 259 260 simplex->gamma_sum += bracket*multiplier; 261 262 multimap<double,double> map; 263 simplex->gamma_parameters.push_back(map); 264 simplex->gamma_parameters[0].insert(pair<double,double>(bracket*multiplier,a_0-(*as_ref).first)); 265 266 bracket *= fact(sigma_order); 267 257 268 for(int k = 0;k < as1_order-1;k++) 258 269 { 259 double bracket_factor = -pow((double)-1,k+1)*fact(sigma_order-k)/fact(as1_order-1-k)/pow(a_0-(*as_ref).first,sigma_order-k); 270 double local_bracket = 0; 271 double bracket_factor = -pow((double)-1,k+1)/fact(as1_order-1-k)/pow(a_0-(*as_ref).first,sigma_order-k); 260 272 261 273 ivec control_vec = ivec(); 262 control_vec.ins(0,my_emlig->number_of_parameters-as1_order+1); 263 274 control_vec.ins(0,my_emlig->number_of_parameters-as1_order+1); 264 275 265 276 for(multiset<my_ivec>::iterator combi_ref = this->my_emlig->correction_factors[k].begin();combi_ref!=this->my_emlig->correction_factors[k].upper_bound(my_ivec(control_vec));combi_ref++) … … 271 282 272 283 bracket_combination /= factors[(*combi_ref)[j]-1]; 273 } 274 275 bracket+=bracket_factor*bracket_combination; 276 } 277 } 278 279 284 } 285 286 local_bracket += bracket_factor*bracket_combination; 287 } 288 289 simplex->gamma_sum += local_bracket*multiplier; 290 291 if(simplex->gamma_parameters.size()<=k+1) 292 { 293 multimap<double,double> loc_map; 294 simplex->gamma_parameters.push_back(loc_map); 295 } 296 297 simplex->gamma_parameters[k+1].insert(pair<double,double>(local_bracket*multiplier,a_0-(*as_ref).first)); 298 299 bracket += local_bracket*fact(sigma_order-k); 300 } 280 301 281 302 int_value += multiplier*bracket; … … 283 304 } 284 305 285 286 correction_term *= fact(sigma_order)/abs(pow(a_0,sigma_order+1)); 287 288 // cout << c << int_value << endl; 306 double correction_term_base = correction_term/pow(a_0,sigma_order+1); 307 308 simplex->gamma_sum += correction_term_base; 309 simplex->gamma_parameters[0].insert(pair<double,double>(correction_term_base,a_0)); 310 311 correction_term = fact(sigma_order)*correction_term_base; 312 313 //cout << c << int_value << endl; 289 314 290 315 int_value += correction_term; 291 316 292 317 293 // 294 // 318 //cout << "Probability:" << int_value << endl; 319 //pause(0.100); 295 320 296 321 simplex->probability = int_value; -
applications/robust/robustlib.h
r1324 r1325 8 8 #define ROBUST_H 9 9 10 //#include <stat/exp_family.h>10 #include <stat/exp_family.h> 11 11 #include <itpp/itbase.h> 12 12 #include <map> … … 73 73 double probability; 74 74 75 vector<list<pair<double,double>>> gamma_parameters; 75 vector<multimap<double,double>> gamma_parameters; 76 77 double gamma_sum; 78 76 79 77 80 simplex(set<vertex*> vertices) … … 1749 1752 map<double,toprow*> ordered_toprows; 1750 1753 double sum_a = 0; 1751 1752 1754 1753 1755 for(polyhedron* top_ref = statistic.rows[number_of_parameters];top_ref!=statistic.end_poly;top_ref=top_ref->next_poly) … … 1784 1786 set<simplex*>::iterator s_ref; 1785 1787 double sum_b = 0; 1786 1787 1788 for(s_ref = sampled_toprow->triangulation.begin();s_ref!=sampled_toprow->triangulation.end();s_ref++) 1788 1789 { … … 1794 1795 1795 1796 // cout << &(*tri_ref) << endl; 1797 1798 rnumber = randu(); 1799 1800 double sigma = 0; 1801 double sum_g = 0; 1802 for(int i = 0;i<(*s_ref)->gamma_parameters.size();i++) 1803 { 1804 for(multimap<double,double>::iterator g_ref = (*s_ref)->gamma_parameters[i].begin();g_ref != (*s_ref)->gamma_parameters[i].end();g_ref++) 1805 { 1806 sum_g += (*g_ref).first/(*s_ref)->gamma_sum; 1807 1808 if(sum_g>rnumber) 1809 { 1810 itpp::Gamma_RNG* gamma = new itpp::Gamma_RNG(conditions.size()-number_of_parameters,(*g_ref).second); 1811 sigma = (*gamma)(); 1812 break; 1813 } 1814 } 1815 1816 if(sigma!=0) 1817 { 1818 break; 1819 } 1820 } 1796 1821 1797 1822 int dimension = (*s_ref)->vertices.size()-1;