Changeset 1618 for trunk/test


Ignore:
Timestamp:
Nov 6, 2008, 4:58:08 PM (13 years ago)
Author:
Peter
Message:

increasing n and setting margin in a more statistically correct way. The arbitrary constant, 10, is chosen to make it very unlikely to fail by chance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/kolmogorov_smirnov_test.cc

    r1617 r1618  
    7878  double p = ks.p_value(n);
    7979  double p_correct = 2.0/11.0;
    80   double margin = 5*std::sqrt(n*p_correct)/n;
     80  double margin = 10*std::sqrt(p_correct*(1-p_correct)/n);
    8181  if (p>p_correct+margin || p<p_correct-margin) {
    8282    suite.err() << "Error: p-value: " << p << "\n"
     
    9595    ks.add(i+0.5, i<2);
    9696  suite.add(suite.equal(ks.score(), 1.0));
    97   size_t n=1000;
     97  size_t n=100000;
    9898  double p = ks.p_value(n);
    9999  double p_correct = 0.2;
    100   double margin=10*std::sqrt(n*p_correct)/n;
     100  double margin=10*std::sqrt(p_correct*(1-p_correct)/n);
    101101  if (std::abs(p-p_correct)>margin) {
    102102    suite.add(false);
Note: See TracChangeset for help on using the changeset viewer.