Changeset 1272
- Timestamp:
- 01/14/11 18:28:55 (14 years ago)
- Location:
- applications/robust
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/main.cpp
r1271 r1272 14 14 15 15 const int emlig_size = 4; 16 16 17 17 18 int main ( int argc, char* argv[] ) { … … 51 52 for(int k = 0;k<=emlig_size;k++) 52 53 { 53 condition[k] = rand()/1000.0;54 condition[k] = (rand()-RAND_MAX/2)/1000.0; 54 55 } 55 56 … … 58 59 emlig1->add_condition(*condition_vec); 59 60 61 /* 62 for(polyhedron* toprow_ref = emlig1->statistic.rows[emlig_size]; toprow_ref != emlig1->statistic.end_poly; toprow_ref = toprow_ref->next_poly) 63 { 64 cout << ((toprow*)toprow_ref)->probability << endl; 65 } 66 */ 67 60 68 cout << emlig1->statistic_rowsize(emlig_size) << endl << endl; 61 69 70 /* 62 71 if(i-emlig1->number_of_parameters >= 0) 63 72 { 64 73 pause(30); 65 74 } 75 */ 66 76 67 77 // emlig1->step_me(i); 68 78 79 /* 69 80 vector<int> sizevector; 70 81 for(int s = 0;s<=emlig1->number_of_parameters;s++) … … 72 83 sizevector.push_back(emlig1->statistic_rowsize(s)); 73 84 } 85 */ 74 86 } 75 87 -
applications/robust/robustlib.cpp
r1271 r1272 55 55 vec cur_condition = as_toprow->condition.get(1,as_toprow->condition.size()-1); 56 56 57 // cout << as_toprow->condition << endl; 58 57 59 vertex* base_vertex = (*simplex.begin()); 58 60 … … 61 63 mat jacobian(dimension,dimension); 62 64 63 double a_0 = base_vertex->get_coordinates()*cur_condition+as_toprow->condition[0]; 65 // cout << base_vertex->get_coordinates() << endl; 66 67 double a_0 = base_vertex->get_coordinates()*cur_condition-as_toprow->condition[0]; 64 68 map<double,int> as; 65 69 … … 69 73 vec relative_coords = (*vert_ref)->get_coordinates()-base_vertex->get_coordinates(); 70 74 75 // cout << (*vert_ref)->get_coordinates() << endl; 71 76 // cout << relative_coords << endl; 72 77 … … 80 85 (*returned.first).second++; 81 86 } 87 /* 82 88 else 83 89 { 84 90 cout << "a[" << row_count << "] = " << new_a << endl; 85 91 } 92 */ 93 86 94 //as.ins(as.size(),new_a); 87 95 … … 89 97 } 90 98 91 // cout << endl;99 92 100 93 101 double int_value = 0; … … 95 103 // cout << jacobian << endl; 96 104 97 double det_jacobian = det(jacobian); 105 double det_jacobian = abs(det(jacobian)); 106 double correction_term = det_jacobian; 98 107 for(map<double,int>::iterator as_ref = as.begin();as_ref!=as.end();as_ref++) 99 108 { 100 109 double multiplier = det_jacobian; 110 101 111 if(a_0!=(*as_ref).first) 102 { 112 { 103 113 int as1_order = (*as_ref).second; 104 114 115 correction_term /= -pow((*as_ref).first,as1_order); 116 105 117 current_emlig->set_correction_factors(as1_order); 106 118 … … 126 138 multiplier /= (*as_ref).first; 127 139 number_of_factors += 1; 128 } 140 } 141 129 142 } 130 143 131 double bracket = fact(condition_order-number_of_factors)/fact(as1_order-1)/pow( (*as_ref).first-a_0,condition_order-number_of_factors);144 double bracket = fact(condition_order-number_of_factors)/fact(as1_order-1)/pow(a_0+(*as_ref).first,condition_order-number_of_factors+1); 132 145 for(int k = 0;k < as1_order-1;k++) 133 146 { 134 double bracket_factor = pow((double)-1,k+1)*fact(condition_order-1-number_of_factors-k)/fact(as1_order-2-k)/pow( (*as_ref).first-a_0,condition_order-1-number_of_factors-k);147 double bracket_factor = pow((double)-1,k+1)*fact(condition_order-1-number_of_factors-k)/fact(as1_order-2-k)/pow(a_0+(*as_ref).first,condition_order-number_of_factors-k); 135 148 136 149 for(set<my_ivec>::iterator combi_ref = this->my_emlig->correction_factors[k].begin();combi_ref!=this->my_emlig->correction_factors[k].end();combi_ref++) … … 144 157 bracket+=bracket_factor*bracket_combination; 145 158 } 146 } 159 } 147 160 148 int_value += multiplier*bracket;161 149 162 163 int_value += multiplier*bracket; 150 164 } 151 165 else 152 166 { 153 167 throw new exception("Should this happen? a_i=a_0 in the formula for integrating over a simplex! I think it can happen with 0 probability(when phi*2*v_0=phi*v_i)"); 154 } 168 } 169 } 155 170 156 // cout << c << int_value << endl; 171 172 correction_term *= fact(condition_order-my_emlig->number_of_parameters)/pow(a_0,condition_order-my_emlig->number_of_parameters+1); 157 173 158 return int_value; 159 } 174 // cout << c << int_value << endl; 175 176 int_value += correction_term; 177 178 // cout << int_value << endl; 179 180 // cout << "***************************" << endl << endl; 181 182 return int_value; 160 183 161 184 } -
applications/robust/robustlib.h
r1271 r1272 273 273 class c_statistic 274 274 { 275 276 public: 275 277 polyhedron* end_poly; 276 278 polyhedron* start_poly; 277 278 public:279 279 280 280 vector<polyhedron*> rows; … … 567 567 /// A statistic in a form of a Hasse diagram representing a complex of convex polyhedrons obtained as a result 568 568 /// of data update from Bayesian estimation or set by the user if this emlig is a prior density 569 c_statistic statistic;569 570 570 571 571 vector<list<polyhedron*>> for_splitting; … … 787 787 788 788 public: 789 c_statistic statistic; 789 790 790 791 vector<set<my_ivec>> correction_factors;