source: branches/0.4-stable/test/fisher_test.cc @ 1621

Last change on this file since 1621 was 1621, checked in by Peter, 15 years ago

fixes #460

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: fisher_test.cc 1621 2008-11-10 21:39:48Z peter $
2
3/*
4  Copyright (C) 2008 Peter Johansson
5
6  This file is part of the yat library, http://dev.thep.lu.se/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 3 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with yat. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "Suite.h"
23
24#include "yat/statistics/Fisher.h"
25
26int main(int argc, char* argv[])
27{ 
28  using namespace theplu::yat;
29  test::Suite suite(argc, argv);
30
31  statistics::Fisher f;
32  if (!suite.equal(f.oddsratio(1,4,5,1), 0.05)) {
33    suite.add(false);
34    suite.err() << "oddsratio failed\n";
35  }
36  double a, b, c, d;
37  f.expected(a,b,c,d);
38  if (!suite.equal(a, 30.0/11.0)) {
39    suite.add(false);
40    suite.err() << "expected a failed\n";
41  }
42  if (!suite.equal(b, 25.0/11.0)) {
43    suite.add(false);
44    suite.err() << "expected b failed\n";
45  }
46  if (!suite.equal(c, 36.0/11.0)) {
47    suite.add(false);
48    suite.err() << "expected c failed\n";
49  }
50  if (!suite.equal(d, 30.0/11.0)) {
51    suite.add(false);
52    suite.err() << "expected d failed\n";
53  }
54  if (!suite.equal(f.Chi2(), 4.4122222222222222222222)) { 
55    suite.add(false);
56    suite.err() << "Chi2 failed\n";
57  }
58  if (!suite.equal(f.minimum_size(),10)) {
59    suite.add(false);
60    suite.err() << "minimum_size failed\n";
61  }
62  return suite.return_value();
63}
Note: See TracBrowser for help on using the repository browser.