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

Dodelani vypoctu pri degenerovanych podminkach. Zda se, ze docela funguje, ale neni zohlednena pocatecni divergence integralu aposteriorna pres parametry. Zbyva odladit. JS

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/robustlib.cpp

    r1262 r1268  
    2020                                        if(should_integrate) 
    2121                                        { 
     22                                                emlig* current_emlig; 
     23 
     24                                                if(this->my_emlig!=NULL) 
     25                                                { 
     26                                                        current_emlig = this->my_emlig; 
     27                                                } 
     28                                                else 
     29                                                { 
     30                                                        throw exception("The statistic of the polyhedron you are trying to integrate over doesn't belong to any emlig!"); 
     31                                                }                                                
     32 
    2233                                                toprow* as_toprow = (toprow*)this; 
    2334 
     
    5364 
    5465                                                double int_value = 0; 
     66                                                double det_jacobian = det(jacobian); 
    5567                                                for(map<double,int>::iterator as_ref = as.begin();as_ref!=as.end();as_ref++) 
    5668                                                { 
    57                                                         int fac_order = ((toprow*)this)->condition_order-as.size()-1; 
     69                                                        int condition_order = ((toprow*)this)->condition_order-1; 
    5870 
    59                                                         double fac_value = 1; 
     71                                                        double multiplier = det_jacobian; 
    6072                                                        if(a_0!=(*as_ref).first) 
    61                                                         { 
    62                                                                 //fac_value = ((double)tgamma(fac_order)*det(jacobian))/(*as_ref).first/pow((*as_ref).first-a_0,fac_order);  
    63                                                                  
    64                                                                 fac_value /= (*as_ref).first; 
     73                                                        {                                                                
     74                                                                int as1_order = (*as_ref).second; 
    6575 
     76                                                                current_emlig->set_correction_factors(as1_order); 
     77 
     78                                                                vector<double> factors; 
     79                                                                int number_of_factors = 0;                                                               
    6680                                                                for(map<double,int>::iterator as2_ref = as.begin();as2_ref!=as.end();as2_ref++) 
    6781                                                                { 
     82                                                                         
    6883                                                                        if(as2_ref!=as_ref) 
     84                                                                        {                                                                                
     85                                                                                for(int k = 0;k<(*as2_ref).second;k++) 
     86                                                                                { 
     87                                                                                        factors.push_back((*as_ref).first-(*as2_ref).first); 
     88                                                                                } 
     89 
     90                                                                                multiplier        /= pow((*as_ref).first-(*as2_ref).first,(*as2_ref).second); 
     91                                                                                number_of_factors += (*as2_ref).second; 
     92                                                                        } 
     93                                                                        else 
    6994                                                                        { 
    70                                                                                 double current_factor = (*as_ref).first-(*as2_ref).first; 
     95                                                                                factors.push_back((*as_ref).first); 
    7196 
    72                                                                                 fac_value /= current_factor; 
     97                                                                                multiplier        /= (*as_ref).first; 
     98                                                                                number_of_factors += 1; 
     99                                                                        }                                                                        
     100                                                                } 
    73101 
    74                                                                                                                                                                  
    75                                                                         } 
    76                                                                 } 
     102                                                                double bracket = fact(condition_order-1-number_of_factors)/fact(as1_order-1)/*/pow((*as_ref).first-a_0,condition_order-1-number_of_factors)*/; 
     103                                                                for(int k = 0;k < as1_order-1;k++) 
     104                                                                { 
     105                                                                        double bracket_factor = pow((double)-1,k+1)*fact(condition_order-2-number_of_factors-k)/fact(as1_order-2-k)/pow((*as_ref).first-a_0,condition_order-2-number_of_factors-k); 
     106                                                                         
     107                                                                        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++) 
     108                                                                        { 
     109                                                                                double bracket_combination = 1; 
     110                                                                                for(int j = 0;j<(*combi_ref).size();j++) 
     111                                                                                { 
     112                                                                                        bracket_combination /= factors[(*combi_ref)[j]]; 
     113                                                                                } 
     114 
     115                                                                                bracket+=bracket_factor*bracket_combination;                                                                     
     116                                                                        }                                                                        
     117                                                                }                                                                
     118 
     119                                                                int_value += multiplier*bracket;         
     120 
    77121                                                        } 
    78122                                                        else 
    79123                                                        { 
    80124                                                                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)"); 
    81                                                         } 
    82  
    83                                                          
    84                                                         int_value += fac_value;                                                  
     125                                                        }                                                
     126                                                                                                         
    85127                                                } 
    86128