yat/statistics/LikelihoodRatioTestBinomial.h

Code
Comments
Other
Rev Date Author Line
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 4 // $Id$
3134 27 Nov 13 peter 5
3134 27 Nov 13 peter 6 /*
3134 27 Nov 13 peter 7   Copyright (C) 2013 Peter Johansson
3134 27 Nov 13 peter 8
3134 27 Nov 13 peter 9   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 11   The yat library is free software; you can redistribute it and/or
3134 27 Nov 13 peter 12   modify it under the terms of the GNU General Public License as
3134 27 Nov 13 peter 13   published by the Free Software Foundation; either version 3 of the
3134 27 Nov 13 peter 14   License, or (at your option) any later version.
3134 27 Nov 13 peter 15
3134 27 Nov 13 peter 16   The yat library is distributed in the hope that it will be useful,
3134 27 Nov 13 peter 17   but WITHOUT ANY WARRANTY; without even the implied warranty of
3134 27 Nov 13 peter 18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3134 27 Nov 13 peter 19   General Public License for more details.
3134 27 Nov 13 peter 20
3134 27 Nov 13 peter 21   You should have received a copy of the GNU General Public License
3134 27 Nov 13 peter 22   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 32      \brief Likelihood-ratio test for binomial data
3134 27 Nov 13 peter 33
3134 27 Nov 13 peter 34      This class is useful when having binomial data for several
3134 27 Nov 13 peter 35      populations and especially comparing the frequency in the
3134 27 Nov 13 peter 36      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 42        \brief constructor
3134 27 Nov 13 peter 43        \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 48        \brief add one data point
3134 27 Nov 13 peter 49        \param population from which population the data point comes from.
3134 27 Nov 13 peter 50        \param positive if \c true data point is positive.
3134 27 Nov 13 peter 51        \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 56        \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 61        \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 66        \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 71        \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 76        \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 81        \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 86        \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 91        \brief Calculate natural logarithm of likelihood ratios
3138 29 Nov 13 peter 92
3138 29 Nov 13 peter 93        The logairithm of the likelihood ratio is calculated as
3138 29 Nov 13 peter 94        \f$ LLR = \sum_i \left ( n_{i+} \ln \frac{n_{i+}}{n_i} +
3138 29 Nov 13 peter 95        n_{i-} \ln \frac{n_{i-}}{n_i} \right ) -
3138 29 Nov 13 peter 96        \left ( n_+ \ln \frac{n_+}{n} +
3138 29 Nov 13 peter 97        n_- \ln \frac{n_-}{n} \right )
3138 29 Nov 13 peter 98        \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