Show
Ignore:
Timestamp:
01/14/11 18:28:55 (13 years ago)
Author:
sindj
Message:

Dodelano pocitani, odstranena chyba se zapornymi pravdepodobnostmi. JS

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/robustlib.cpp

    r1271 r1272  
    5555                        vec cur_condition = as_toprow->condition.get(1,as_toprow->condition.size()-1); 
    5656 
     57                        // cout << as_toprow->condition << endl; 
     58 
    5759                        vertex* base_vertex = (*simplex.begin()); 
    5860 
     
    6163                        mat jacobian(dimension,dimension); 
    6264 
    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]; 
    6468                        map<double,int> as; 
    6569 
     
    6973                                vec relative_coords = (*vert_ref)->get_coordinates()-base_vertex->get_coordinates(); 
    7074 
     75                                // cout << (*vert_ref)->get_coordinates() << endl; 
    7176                                // cout << relative_coords << endl; 
    7277 
     
    8085                                        (*returned.first).second++; 
    8186                                } 
     87                                /* 
    8288                                else 
    8389                                { 
    8490                                        cout << "a[" << row_count << "] = " << new_a << endl; 
    8591                                } 
     92                                */ 
     93                                 
    8694                                //as.ins(as.size(),new_a);                                                       
    8795                                 
     
    8997                        } 
    9098 
    91                         // cout << endl; 
     99                         
    92100 
    93101                        double int_value = 0; 
     
    95103                        // cout << jacobian << endl; 
    96104 
    97                         double det_jacobian = det(jacobian); 
     105                        double det_jacobian    = abs(det(jacobian)); 
     106                        double correction_term = det_jacobian;                   
    98107                        for(map<double,int>::iterator as_ref = as.begin();as_ref!=as.end();as_ref++) 
    99108                        { 
    100109                                double multiplier = det_jacobian; 
     110                                 
    101111                                if(a_0!=(*as_ref).first) 
    102                                 {                                                                
     112                                { 
    103113                                        int as1_order = (*as_ref).second; 
    104  
     114                                         
     115                                        correction_term /= -pow((*as_ref).first,as1_order);                                      
     116                                         
    105117                                        current_emlig->set_correction_factors(as1_order); 
    106118 
     
    126138                                                        multiplier        /= (*as_ref).first; 
    127139                                                        number_of_factors += 1; 
    128                                                 }                                                                        
     140                                                } 
     141                                                 
    129142                                        }                                        
    130143 
    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); 
    132145                                        for(int k = 0;k < as1_order-1;k++) 
    133146                                        { 
    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); 
    135148                                                 
    136149                                                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++) 
     
    144157                                                        bracket+=bracket_factor*bracket_combination;                                                                     
    145158                                                }                                                                        
    146                                         }                                                                
     159                                        } 
    147160 
    148                                         int_value += multiplier*bracket;         
     161                                         
    149162 
     163                                        int_value += multiplier*bracket; 
    150164                                } 
    151165                                else 
    152166                                { 
    153167                                        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                        } 
    155170 
    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); 
    157173 
    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; 
    160183                         
    161184                }