3134 |
27 Nov 13 |
peter |
1 |
#ifndef _theplu_yat_statistics_loglikelihood_ratio_test_binomial |
3134 |
27 Nov 13 |
peter |
2 |
#define _theplu_yat_statistics_loglikelihood_ratio_test_binomial |
3134 |
27 Nov 13 |
peter |
3 |
|
3134 |
27 Nov 13 |
peter |
// $Id$ |
3134 |
27 Nov 13 |
peter |
5 |
|
3134 |
27 Nov 13 |
peter |
6 |
/* |
3134 |
27 Nov 13 |
peter |
Copyright (C) 2013 Peter Johansson |
3134 |
27 Nov 13 |
peter |
8 |
|
3134 |
27 Nov 13 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
3134 |
27 Nov 13 |
peter |
10 |
|
3134 |
27 Nov 13 |
peter |
The yat library is free software; you can redistribute it and/or |
3134 |
27 Nov 13 |
peter |
modify it under the terms of the GNU General Public License as |
3134 |
27 Nov 13 |
peter |
published by the Free Software Foundation; either version 3 of the |
3134 |
27 Nov 13 |
peter |
License, or (at your option) any later version. |
3134 |
27 Nov 13 |
peter |
15 |
|
3134 |
27 Nov 13 |
peter |
The yat library is distributed in the hope that it will be useful, |
3134 |
27 Nov 13 |
peter |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
3134 |
27 Nov 13 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3134 |
27 Nov 13 |
peter |
General Public License for more details. |
3134 |
27 Nov 13 |
peter |
20 |
|
3134 |
27 Nov 13 |
peter |
You should have received a copy of the GNU General Public License |
3134 |
27 Nov 13 |
peter |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
3134 |
27 Nov 13 |
peter |
23 |
*/ |
3134 |
27 Nov 13 |
peter |
24 |
|
3138 |
29 Nov 13 |
peter |
25 |
#include "yat/utility/Matrix.h" |
3134 |
27 Nov 13 |
peter |
26 |
|
3134 |
27 Nov 13 |
peter |
27 |
namespace theplu { |
3134 |
27 Nov 13 |
peter |
28 |
namespace yat { |
3134 |
27 Nov 13 |
peter |
29 |
namespace statistics { |
3134 |
27 Nov 13 |
peter |
30 |
|
3134 |
27 Nov 13 |
peter |
31 |
/** |
3138 |
29 Nov 13 |
peter |
\brief Likelihood-ratio test for binomial data |
3134 |
27 Nov 13 |
peter |
33 |
|
3134 |
27 Nov 13 |
peter |
This class is useful when having binomial data for several |
3134 |
27 Nov 13 |
peter |
populations and especially comparing the frequency in the |
3134 |
27 Nov 13 |
peter |
differen samples. |
3134 |
27 Nov 13 |
peter |
37 |
*/ |
3138 |
29 Nov 13 |
peter |
38 |
class LikelihoodRatioTestBinomial |
3134 |
27 Nov 13 |
peter |
39 |
{ |
3134 |
27 Nov 13 |
peter |
40 |
public: |
3134 |
27 Nov 13 |
peter |
41 |
/** |
3134 |
27 Nov 13 |
peter |
\brief constructor |
3134 |
27 Nov 13 |
peter |
\param n number of populations in data |
3134 |
27 Nov 13 |
peter |
44 |
*/ |
3138 |
29 Nov 13 |
peter |
45 |
LikelihoodRatioTestBinomial(size_t n=2); |
3134 |
27 Nov 13 |
peter |
46 |
|
3134 |
27 Nov 13 |
peter |
47 |
/** |
3134 |
27 Nov 13 |
peter |
\brief add one data point |
3134 |
27 Nov 13 |
peter |
\param population from which population the data point comes from. |
3134 |
27 Nov 13 |
peter |
\param positive if \c true data point is positive. |
3134 |
27 Nov 13 |
peter |
\param n how many data points added |
3134 |
27 Nov 13 |
peter |
52 |
*/ |
3134 |
27 Nov 13 |
peter |
53 |
void add(size_t population, bool positive, long int n=1); |
3134 |
27 Nov 13 |
peter |
54 |
|
3134 |
27 Nov 13 |
peter |
55 |
/** |
3134 |
27 Nov 13 |
peter |
\return Number of data points |
3134 |
27 Nov 13 |
peter |
57 |
*/ |
3134 |
27 Nov 13 |
peter |
58 |
unsigned long int n(void) const; |
3134 |
27 Nov 13 |
peter |
59 |
|
3134 |
27 Nov 13 |
peter |
60 |
/** |
3134 |
27 Nov 13 |
peter |
\return Number of data points from population \a i |
3134 |
27 Nov 13 |
peter |
62 |
*/ |
3134 |
27 Nov 13 |
peter |
63 |
unsigned long int n(size_t i) const; |
3134 |
27 Nov 13 |
peter |
64 |
|
3134 |
27 Nov 13 |
peter |
65 |
/** |
3134 |
27 Nov 13 |
peter |
\return Number of negative data points |
3134 |
27 Nov 13 |
peter |
67 |
*/ |
3134 |
27 Nov 13 |
peter |
68 |
unsigned long int negative(void) const; |
3134 |
27 Nov 13 |
peter |
69 |
|
3134 |
27 Nov 13 |
peter |
70 |
/** |
3134 |
27 Nov 13 |
peter |
\return Number of negative data points from population \a i |
3134 |
27 Nov 13 |
peter |
72 |
*/ |
3134 |
27 Nov 13 |
peter |
73 |
unsigned long int negative(size_t i) const; |
3134 |
27 Nov 13 |
peter |
74 |
|
3134 |
27 Nov 13 |
peter |
75 |
/** |
3134 |
27 Nov 13 |
peter |
\return Number of data points |
3134 |
27 Nov 13 |
peter |
77 |
*/ |
3134 |
27 Nov 13 |
peter |
78 |
unsigned long int positive(void) const; |
3134 |
27 Nov 13 |
peter |
79 |
|
3134 |
27 Nov 13 |
peter |
80 |
/** |
3134 |
27 Nov 13 |
peter |
\return Number of positive data points from population \a i |
3134 |
27 Nov 13 |
peter |
82 |
*/ |
3134 |
27 Nov 13 |
peter |
83 |
unsigned long int positive(size_t i) const; |
3134 |
27 Nov 13 |
peter |
84 |
|
3134 |
27 Nov 13 |
peter |
85 |
/** |
3134 |
27 Nov 13 |
peter |
\return Number of populations |
3134 |
27 Nov 13 |
peter |
87 |
*/ |
3134 |
27 Nov 13 |
peter |
88 |
size_t size(void) const; |
3134 |
27 Nov 13 |
peter |
89 |
|
3134 |
27 Nov 13 |
peter |
90 |
/** |
3134 |
27 Nov 13 |
peter |
\brief Calculate natural logarithm of likelihood ratios |
3138 |
29 Nov 13 |
peter |
92 |
|
3138 |
29 Nov 13 |
peter |
The logairithm of the likelihood ratio is calculated as |
3138 |
29 Nov 13 |
peter |
\f$ LLR = \sum_i \left ( n_{i+} \ln \frac{n_{i+}}{n_i} + |
3138 |
29 Nov 13 |
peter |
n_{i-} \ln \frac{n_{i-}}{n_i} \right ) - |
3138 |
29 Nov 13 |
peter |
\left ( n_+ \ln \frac{n_+}{n} + |
3138 |
29 Nov 13 |
peter |
n_- \ln \frac{n_-}{n} \right ) |
3138 |
29 Nov 13 |
peter |
\f$ |
3134 |
27 Nov 13 |
peter |
99 |
*/ |
3138 |
29 Nov 13 |
peter |
100 |
double llr(void) const; |
3134 |
27 Nov 13 |
peter |
101 |
|
3134 |
27 Nov 13 |
peter |
102 |
private: |
3138 |
29 Nov 13 |
peter |
103 |
utility::Matrix count_; |
3134 |
27 Nov 13 |
peter |
104 |
}; |
3134 |
27 Nov 13 |
peter |
105 |
|
3134 |
27 Nov 13 |
peter |
106 |
}}} // of namespace theplu yat statistics |
3134 |
27 Nov 13 |
peter |
107 |
|
3134 |
27 Nov 13 |
peter |
108 |
#endif |