Changeset 1624 for branches/0.4stable/test/fisher_test.cc
 Timestamp:
 Nov 12, 2008, 11:10:52 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/0.4stable/test/fisher_test.cc
r1621 r1624 24 24 #include "yat/statistics/Fisher.h" 25 25 26 using namespace theplu::yat; 27 void test_p_value(test::Suite&); 28 void test_p_value_approximative(test::Suite&); 29 void test_p_value_exact(test::Suite&); 30 26 31 int main(int argc, char* argv[]) 27 32 { 28 using namespace theplu::yat;29 33 test::Suite suite(argc, argv); 30 34 … … 60 64 suite.err() << "minimum_size failed\n"; 61 65 } 66 test_p_value(suite); 62 67 return suite.return_value(); 63 68 } 69 70 71 void test_p_value(test::Suite& suite) 72 { 73 test_p_value_exact(suite); 74 test_p_value_approximative(suite); 75 } 76 77 78 void 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 91 void 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.