yat  0.14.5pre
Fisher.h
1 #ifndef _theplu_yat_statistics_fisher_
2 #define _theplu_yat_statistics_fisher_
3 
4 // $Id: Fisher.h 3562 2017-01-04 01:16:07Z peter $
5 
6 /*
7  Copyright (C) 2004, 2005 Peter Johansson
8  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
9  Copyright (C) 2009, 2011, 2013, 2014, 2015, 2017 Peter Johansson
10 
11  This file is part of the yat library, http://dev.thep.lu.se/yat
12 
13  The yat library is free software; you can redistribute it and/or
14  modify it under the terms of the GNU General Public License as
15  published by the Free Software Foundation; either version 3 of the
16  License, or (at your option) any later version.
17 
18  The yat library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with yat. If not, see <http://www.gnu.org/licenses/>.
25 */
26 
27 #include <yat/utility/deprecate.h>
28 
29 namespace theplu {
30 namespace yat {
31 namespace statistics {
32 
65  class Fisher
66  {
67 
68  public:
77  Fisher(bool yates=false);
78 
82  virtual ~Fisher(void);
83 
84 
98  double Chi2(void) const;
99 
107  void expected(double& a, double& b, double& c, double& d) const;
108 
115  unsigned int& minimum_size(void);
116 
123  const unsigned int& minimum_size(void) const;
124 
133  double p_left(void) const;
134 
143  double p_right(void) const;
144 
156  double p_value(void) const;
157 
169  double p_value_one_sided() const YAT_DEPRECATE;
170 
184  double oddsratio(const unsigned int a, const unsigned int b,
185  const unsigned int c, const unsigned int d);
186 
192  double oddsratio(void) const;
193 
194  private:
195  bool calculate_p_exact(void) const;
196 
197  // two-sided
198  double p_value_approximative(void) const;
199  // two-sided
200  double p_value_exact(void) const;
201  // calculate two-sided p-value to get k (or fewer) wins when
202  // drawing t samples out of of a population of n1 wins and n2 losses
203  double p_value_exact(unsigned int k, unsigned int n1, unsigned int n2,
204  unsigned int t) const;
205 
206  double lower_tail(unsigned int k, unsigned int n1, unsigned int n2,
207  unsigned int t) const;
208 
209  // return P(X=k+1) / P(X=k)
210  double hypergeometric_ratio(unsigned int k, unsigned int n1,
211  unsigned int n2, unsigned int t) const;
212  double choose_ratio(unsigned int n, unsigned int k) const;
213 
214  double p_left_exact(void) const;
215  double p_right_exact(void) const;
216 
217  double yates(unsigned int o, double e) const;
218 
219  unsigned int a_;
220  unsigned int b_;
221  unsigned int c_;
222  unsigned int d_;
223  unsigned int minimum_size_;
224  double oddsratio_;
225  bool yates_;
226  };
227 
228 }}} // of namespace statistics, yat, and theplu
229 
230 #endif
double p_value(void) const
double p_left(void) const
Fisher&#39;s exact test.
Definition: Fisher.h:65
unsigned int & minimum_size(void)
double oddsratio(void) const
double p_right(void) const
void expected(double &a, double &b, double &c, double &d) const

Generated on Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5