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/test/statistics_test.cc

    r1418 r1420  
    9797  x.reserve(6);
    9898  for (unsigned int i=0; i<5; i++){
    99     x.push_back(static_cast<double>(i));
     99    x.push_back(static_cast<double>(i+1));
    100100  }
    101   test_percentiler(suite, x.begin(), x.end(), 50, 2);
    102   x.push_back(5);
    103   test_percentiler(suite, x.begin(), x.end(), 50, 2.5);
    104   test_percentiler(suite, x.begin(), x.end(), 25, 1);
    105   test_percentiler(suite, x.begin(), x.end(), 0, 0);
    106   test_percentiler(suite, x.begin(), x.end(), 10, 0);
     101  test_percentiler(suite, x.begin(), x.end(), 50, 3);
     102  x.push_back(6);
     103  test_percentiler(suite, x.begin(), x.end(), 50, 3.5);
     104  test_percentiler(suite, x.begin(), x.end(), 25, 2);
     105  test_percentiler(suite, x.begin(), x.end(), 0, 1);
     106  test_percentiler(suite, x.begin(), x.end(), 10, 1);
    107107
    108108  suite.err() << "testing duplication of data\n";
     
    122122  }
    123123  const std::vector<utility::DataWeight> xw_orig(xw);
     124  suite.err() << "testing weighted" << std::endl;
     125  test_percentiler(suite, xw.begin(), xw.end(), 0, 1);
     126  test_percentiler(suite, xw.begin(), xw.end(), 100, 6);
     127  test_percentiler(suite, xw.begin(), xw.end(), 49, 3);
     128  test_percentiler(suite, xw.begin(), xw.end(), 51, 4);
     129  test_percentiler(suite, xw.begin(), xw.end(), 50, 3.5);
     130  test_percentiler(suite, x.begin(), x.end(), 10, 1);
     131
    124132  suite.err() << "testing weighted with unity weights" << std::endl;
    125133  cmp_percentiler(suite, x.begin(), x.end(), xw.begin(), xw.end());
     
    149157  double x = percentile2(first, last, p);
    150158  if (!suite.add(suite.equal(x, correct, 10))) {
    151     suite.err() << "Error in percentile2\n";
     159    suite.err() << "Error in percentile2 for " << p << "th percentile \n";
    152160    suite.err() << "  calculated value: " << x << "\n";
    153161    suite.err() << "  expected value: " << correct << "\n";
Note: See TracChangeset for help on using the changeset viewer.