yat/statistics/PearsonCorrelation.h

Code
Comments
Other
Rev Date Author Line
779 05 Mar 07 peter 1 #ifndef _theplu_yat_statistics_pearson_correlation_
3005 24 Mar 13 peter 2 #define _theplu_yat_statistics_pearson_correlation_
139 20 Aug 04 peter 3
616 31 Aug 06 jari 4 // $Id$
616 31 Aug 06 jari 5
675 10 Oct 06 jari 6 /*
831 27 Mar 07 peter 7   Copyright (C) 2004, 2005 Peter Johansson
2119 12 Dec 09 peter 8   Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
4359 23 Aug 23 peter 9   Copyright (C) 2007 Peter Johansson
4359 23 Aug 23 peter 10   Copyright (C) 2008 Jari Häkkinen, Peter Johansson
3114 10 Nov 13 peter 11   Copyright (C) 2009, 2013 Peter Johansson
139 20 Aug 04 peter 12
1437 25 Aug 08 peter 13   This file is part of the yat library, http://dev.thep.lu.se/yat
675 10 Oct 06 jari 14
675 10 Oct 06 jari 15   The yat library is free software; you can redistribute it and/or
675 10 Oct 06 jari 16   modify it under the terms of the GNU General Public License as
1486 09 Sep 08 jari 17   published by the Free Software Foundation; either version 3 of the
675 10 Oct 06 jari 18   License, or (at your option) any later version.
675 10 Oct 06 jari 19
675 10 Oct 06 jari 20   The yat library is distributed in the hope that it will be useful,
675 10 Oct 06 jari 21   but WITHOUT ANY WARRANTY; without even the implied warranty of
675 10 Oct 06 jari 22   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
675 10 Oct 06 jari 23   General Public License for more details.
675 10 Oct 06 jari 24
675 10 Oct 06 jari 25   You should have received a copy of the GNU General Public License
1487 10 Sep 08 jari 26   along with yat. If not, see <http://www.gnu.org/licenses/>.
675 10 Oct 06 jari 27 */
675 10 Oct 06 jari 28
1139 24 Feb 08 peter 29 #include "AveragerPairWeighted.h"
675 10 Oct 06 jari 30
3005 24 Mar 13 peter 31 #include "yat/utility/deprecate.h"
3005 24 Mar 13 peter 32
295 29 Apr 05 peter 33 namespace theplu {
680 11 Oct 06 jari 34 namespace yat {
1006 24 Jan 08 peter 35 namespace statistics {
149 09 Sep 04 peter 36
1006 24 Jan 08 peter 37   ///
1006 24 Jan 08 peter 38   /// @brief Class for calculating Pearson correlation.
3005 24 Mar 13 peter 39   ///
779 05 Mar 07 peter 40   class PearsonCorrelation
1006 24 Jan 08 peter 41   {
1006 24 Jan 08 peter 42   public:
139 20 Aug 04 peter 43     ///
1006 24 Jan 08 peter 44     /// @brief The default constructor.
1006 24 Jan 08 peter 45     ///
1006 24 Jan 08 peter 46     PearsonCorrelation(void);
3005 24 Mar 13 peter 47
1006 24 Jan 08 peter 48     ///
1006 24 Jan 08 peter 49     /// @brief The destructor.
1006 24 Jan 08 peter 50     ///
1006 24 Jan 08 peter 51     virtual ~PearsonCorrelation(void);
3005 24 Mar 13 peter 52
1006 24 Jan 08 peter 53     /**
1145 25 Feb 08 peter 54        Adding a data value to PearsonCorrelation.
1145 25 Feb 08 peter 55     */
1145 25 Feb 08 peter 56     void add(double value, bool target, double weight=1.0);
1139 24 Feb 08 peter 57
1006 24 Jan 08 peter 58     /**
1145 25 Feb 08 peter 59        \brief correlation
1139 24 Feb 08 peter 60
1145 25 Feb 08 peter 61        Correlation is calculated as implemented in AveragerPairWeighted
1139 24 Feb 08 peter 62
1145 25 Feb 08 peter 63        @return Pearson correlation.
1006 24 Jan 08 peter 64     */
1145 25 Feb 08 peter 65     double score(void) const;
3005 24 Mar 13 peter 66
1006 24 Jan 08 peter 67     /**
3005 24 Mar 13 peter 68        \deprecated Provided for backward compatibility with the 0.10
3005 24 Mar 13 peter 69        API. Use p_right(void).
3005 24 Mar 13 peter 70     */
3005 24 Mar 13 peter 71     double p_value_one_sided(void) const YAT_DEPRECATE;
3005 24 Mar 13 peter 72
3005 24 Mar 13 peter 73     /**
3005 24 Mar 13 peter 74        Similar to p_right, but returns probability to get observed
3005 24 Mar 13 peter 75        correlation or less.
3005 24 Mar 13 peter 76
3005 24 Mar 13 peter 77        \since New in yat 0.11
3005 24 Mar 13 peter 78      */
3005 24 Mar 13 peter 79     double p_left(void) const;
3005 24 Mar 13 peter 80
3005 24 Mar 13 peter 81     /**
1006 24 Jan 08 peter 82        The p-value is the probability of getting a correlation as
1006 24 Jan 08 peter 83        large (or larger) as the observed value by random chance, when the true
3005 24 Mar 13 peter 84        correlation is zero (and the data is Gaussian).
3005 24 Mar 13 peter 85
1145 25 Feb 08 peter 86        P-value is calculated using function pearson_p_value(double,
1271 09 Apr 08 peter 87        unsigned int) where degrees of freedom is calculated using n(void) in
1145 25 Feb 08 peter 88        AveragerPairWeighted.
1145 25 Feb 08 peter 89
1006 24 Jan 08 peter 90        @return one-sided p-value
1886 31 Mar 09 peter 91
3005 24 Mar 13 peter 92        \since New in yat 0.11
1006 24 Jan 08 peter 93     */
3005 24 Mar 13 peter 94     double p_right(void) const;
3005 24 Mar 13 peter 95
3005 24 Mar 13 peter 96     /**
3005 24 Mar 13 peter 97        Claculates the probability to get correlation greater than |r|
3005 24 Mar 13 peter 98        or less than -|r|.
3005 24 Mar 13 peter 99
3005 24 Mar 13 peter 100        \return two-sided p-value
3005 24 Mar 13 peter 101
3005 24 Mar 13 peter 102        \since New in yat 0.11
3005 24 Mar 13 peter 103      */
3005 24 Mar 13 peter 104     double p_value(void) const;
3005 24 Mar 13 peter 105
1006 24 Jan 08 peter 106   private:
1145 25 Feb 08 peter 107     AveragerPairWeighted ap_;
139 20 Aug 04 peter 108   };
3005 24 Mar 13 peter 109
683 11 Oct 06 jari 110 }}} // of namespace statistics, yat, and theplu
139 20 Aug 04 peter 111 #endif