Changeset 2315
 Timestamp:
 Aug 20, 2010, 5:51:00 AM (12 years ago)
 Location:
 branches/0.6stable
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

branches/0.6stable/test/fisher_test.cc
r2314 r2315 123 123 void test_large_numbers(test::Suite& suite) 124 124 { 125 // skip test if unsigned int is 16 bit 126 if (UINT_MAX == ( 1 << 16)) 127 return; 128 125 129 statistics::Fisher f; 126 130 double oddsratio = f.oddsratio(1166,633268251166,1095,660747591095); … … 130 134 suite.xadd(false); 131 135 } 132 136 f.p_value(); 137 f.p_value_one_sided(); 133 138 } 
branches/0.6stable/yat/statistics/Fisher.cc
r2119 r2315 30 30 31 31 #include <algorithm> 32 #include <cassert> 32 33 33 34 namespace theplu { … … 64 65 void Fisher::expected(double& a, double& b, double& c, double& d) const 65 66 { 66 double N = a_+b_+c_+d_; 67 // use floting point arithmetic to avoid overflow 68 double N = static_cast<double>(a_) + static_cast<double>(b_) 69 + static_cast<double>(c_) + static_cast<double>(d_); 67 70 a =((a_+b_)*(a_+c_)) / N; 68 71 b =((a_+b_)*(b_+d_)) / N; … … 98 101 d_ = d; 99 102 100 oddsratio_=static_cast<double>(a*d)/static_cast<double>(b*c); 103 oddsratio_= (static_cast<double>(a) / static_cast<double>(b) * 104 static_cast<double>(d) / static_cast<double>(c) ); 101 105 return oddsratio_; 102 106 } … … 118 122 return p_value_approximative()/2.0; 119 123 } 124 // check for overflow 125 assert(c_ <= c_+d_ && d_ <= c_+d_); 126 assert(a_ <= a_+b_ && b_ <= a_+b_); 127 assert(a_ <= a_+c_ && c_ <= a_+c_); 128 120 129 return statistics::cdf_hypergeometric_P(c_, c_+d_, a_+b_, a_+c_); 121 130 } … … 147 156 } 148 157 149 150 158 }}} // of namespace statistics, yat, and theplu
Note: See TracChangeset
for help on using the changeset viewer.