Changeset 2595
- Timestamp:
- Oct 30, 2011, 4:27:20 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/roc.cc
r2593 r2595 124 124 -+++- 3 3 125 125 -++-+ 2 2 126 -+-++ 1 0.5 126 -+-++ 1 0.5 *** our second case *** 127 127 --+++ 0 0.5 128 128 */ … … 145 145 else 146 146 suite.add(true); 147 148 suite.out() << "test p exact with ties II\n"; 149 roc.reset(); 150 roc.add(2, false); 151 roc.add(1, true); 152 roc.add(1, false); 153 roc.add(0, true); 154 roc.add(-1, true); 155 suite.add(suite.equal(roc.area(), 0.5/6)); 156 if (!suite.add(suite.equal(roc.p_value_one_sided(), 10.0/10.0))) 157 suite.out() << " p_value_one_sided: expected 0.3\n"; 158 if (!suite.add(suite.equal(roc.p_value(), 3.0/10.0))) 159 suite.out() << " (two-sided) p_value: expected 0.5\n"; 147 160 } 148 161 … … 183 196 roc.add(i, i<5); 184 197 if (roc.p_value_one_sided()<0.5) { 185 suite. xadd(false);198 suite.add(false); 186 199 suite.err() << "error: expected p-value>0.5\n found: " 187 200 << roc.p_value_one_sided() << "\n"; 188 201 } 189 190 202 } 191 203 -
trunk/yat/statistics/ROC.cc
r2592 r2595 27 27 #include <gsl/gsl_cdf.h> 28 28 29 #include <algorithm> 29 30 #include <cassert> 30 31 #include <cmath> … … 137 138 double ROC::p_exact(double area) const 138 139 { 139 if (area>=0.5) 140 return p_exact_with_ties(multimap_.begin(), multimap_.end(), 141 area*w_pos_*w_neg_, w_pos_, w_neg_); 142 return p_exact_with_ties(multimap_.rbegin(), multimap_.rend(), 143 (1.0-area)*w_pos_*w_neg_, w_pos_, w_neg_); 144 145 140 return p_exact_with_ties(multimap_.begin(), multimap_.end(), 141 area*w_pos_*w_neg_, w_pos_, w_neg_); 146 142 } 147 143 … … 156 152 if (use_exact_method()) { 157 153 double p = 0; 158 p = p_exact(area); 154 double abs_area = std::max(area, 1-area); 155 p = p_exact(abs_area); 159 156 if (has_ties_) { 160 p += p_exact(1-area); 157 p += p_exact_with_ties(multimap_.rbegin(), multimap_.rend(), 158 abs_area*w_pos_*w_neg_, w_pos_, w_neg_); 161 159 } 162 160 else
Note: See TracChangeset
for help on using the changeset viewer.