Changeset 1039
- Timestamp:
- Feb 6, 2008, 1:20:31 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/statistics_test.cc
r1000 r1039 46 46 if (m!=4.5 || m!=m_gsl) 47 47 return -1; 48 statistics::percentile(data.begin(), data.end(), 100); 49 data.resize(1); 50 statistics::median(data.begin(), data.end()); 48 51 49 52 double tolerance=1e-10; -
trunk/yat/statistics/utility.h
r1025 r1039 181 181 std::copy(first, last, std::back_inserter(v_copy)); 182 182 double j = p/100 * (v_copy.size()-1); 183 int i = static_cast<int>(j); 184 std::partial_sort(v_copy.begin(),v_copy.begin()+i+2 , v_copy.end()); 183 size_t i = static_cast<size_t>(j); 184 if (i+2 < v_copy.size()) { 185 utility::yat_assert<std::out_of_range>(i+2 < v_copy.size(), 186 "in utility::percentile"); 187 std::partial_sort(v_copy.begin(), v_copy.begin()+i+2, v_copy.end()); 188 } 189 else 190 std::sort(v_copy.begin(), v_copy.end()); 191 185 192 return percentile(v_copy.begin(), v_copy.end(), p, true); 186 193 }
Note: See TracChangeset
for help on using the changeset viewer.