Changeset 1039 for trunk/yat/statistics


Ignore:
Timestamp:
Feb 6, 2008, 1:20:31 AM (13 years ago)
Author:
Peter
Message:

fixes #276

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/utility.h

    r1025 r1039  
    181181    std::copy(first, last, std::back_inserter(v_copy));
    182182    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     
    185192    return percentile(v_copy.begin(), v_copy.end(), p, true);
    186193  }
Note: See TracChangeset for help on using the changeset viewer.