Ignore:
Timestamp:
Nov 12, 2008, 11:10:52 PM (14 years ago)
Author:
Peter
Message:

fixes #461. Also modified implementation of cdf_hypergeometric_P, which may cause conflict with modifications done in trunk (refs #87). If so, go with the trunk version (which uses GSL 1.8).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.4-stable/test/fisher_test.cc

    r1621 r1624  
    2424#include "yat/statistics/Fisher.h"
    2525
     26using namespace theplu::yat;
     27void test_p_value(test::Suite&);
     28void test_p_value_approximative(test::Suite&);
     29void test_p_value_exact(test::Suite&);
     30
    2631int main(int argc, char* argv[])
    2732
    28   using namespace theplu::yat;
    2933  test::Suite suite(argc, argv);
    3034
     
    6064    suite.err() << "minimum_size failed\n";
    6165  }
     66  test_p_value(suite);
    6267  return suite.return_value();
    6368}
     69
     70
     71void test_p_value(test::Suite& suite)
     72{
     73  test_p_value_exact(suite);
     74  test_p_value_approximative(suite);
     75}
     76
     77
     78void test_p_value_approximative(test::Suite& suite)
     79{
     80  suite.err() << "testing p_value_approximative\n";
     81  statistics::Fisher f;
     82  f.minimum_size() = 0;
     83  f.oddsratio(10,20,20,50);
     84  suite.add(suite.equal(f.p_value(), 2*f.p_value_one_sided()));
     85  f.oddsratio(10,20,10,20);
     86  suite.add(suite.equal(f.p_value(), 1.0));
     87  suite.add(suite.equal(f.p_value_one_sided(), 0.5));
     88}
     89
     90
     91void test_p_value_exact(test::Suite& suite)
     92{
     93  suite.err() << "test p_value_exact\n";
     94  statistics::Fisher f;
     95  f.minimum_size() = 1000;
     96  f.oddsratio(10,20,10,20);
     97  suite.add(suite.equal(f.p_value(), 1.0));
     98
     99  f.oddsratio(10, 20, 20, 200);
     100  suite.add(suite.equal(f.p_value(), 0.0008119060627676223));
     101  suite.add(suite.equal(f.p_value_one_sided(), 0.0008119060627676223));
     102
     103  // testing symmetry
     104  statistics::Fisher f2;
     105  f2.minimum_size() = 1000;
     106  f2.oddsratio(20, 200, 10, 20);
     107  suite.add(suite.equal(f2.p_value(), f.p_value()));
     108
     109  f.oddsratio(1, 1, 1, 2);
     110  suite.add(suite.equal(f.p_value(), 1.0));
     111  suite.add(suite.equal(f.p_value_one_sided(), 0.7));
     112
     113  f.oddsratio(1, 1, 2, 1);
     114  suite.add(suite.equal(f.p_value(), 1.0));
     115  suite.add(suite.equal(f.p_value_one_sided(), 0.9));
     116
     117}
Note: See TracChangeset for help on using the changeset viewer.