Changeset 1420 for trunk/yat/statistics


Ignore:
Timestamp:
Aug 20, 2008, 7:33:39 PM (13 years ago)
Author:
Peter
Message:

fixing the weighted implementation of Percentiler - refs #366. Some documentation is needed before closing the ticket.

File:
1 edited

Legend:

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

    r1418 r1420  
    146146      double w_bound=perc_/100.0*accum_w.back();
    147147      std::vector<double>::const_iterator upper(accum_w.begin());
    148       double allowed_error=1e-10;
    149       while (upper != accum_w.end() && *upper < w_bound + allowed_error)
     148      double margin=1e-10;
     149      while (*upper <= w_bound+margin && upper!=accum_w.end())
    150150        ++upper;
     151      if (upper==accum_w.end())
     152        --upper;
    151153      std::vector<double>::const_iterator lower(upper);
    152       while (lower!=accum_w.begin() && *lower > w_bound - allowed_error)
     154      while ( *(lower-1)>=w_bound-margin && lower>accum_w.begin())
    153155        --lower;
     156     
    154157      return (trait.data(first+(upper-accum_w.begin()))+
    155               trait.data(first+(lower-accum_w.begin()+1)))/2;
     158              trait.data(first+(lower-accum_w.begin())))/2;
    156159    }
    157160
Note: See TracChangeset for help on using the changeset viewer.