1 | #ifndef _theplu_yat_statistics_pearson_correlation_ |
---|
2 | #define _theplu_yat_statistics_pearson_correlation_ |
---|
3 | |
---|
4 | // $Id: PearsonCorrelation.h 1886 2009-03-31 17:02:39Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2004, 2005 Peter Johansson |
---|
8 | Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér |
---|
9 | Copyright (C) 2007, 2008 Jari Häkkinen, 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 "AveragerPairWeighted.h" |
---|
28 | |
---|
29 | namespace theplu { |
---|
30 | namespace yat { |
---|
31 | namespace statistics { |
---|
32 | |
---|
33 | /// |
---|
34 | /// @brief Class for calculating Pearson correlation. |
---|
35 | /// |
---|
36 | class PearsonCorrelation |
---|
37 | { |
---|
38 | public: |
---|
39 | /// |
---|
40 | /// @brief The default constructor. |
---|
41 | /// |
---|
42 | PearsonCorrelation(void); |
---|
43 | |
---|
44 | /// |
---|
45 | /// @brief The destructor. |
---|
46 | /// |
---|
47 | virtual ~PearsonCorrelation(void); |
---|
48 | |
---|
49 | |
---|
50 | /** |
---|
51 | Adding a data value to PearsonCorrelation. |
---|
52 | */ |
---|
53 | void add(double value, bool target, double weight=1.0); |
---|
54 | |
---|
55 | /** |
---|
56 | \brief correlation |
---|
57 | |
---|
58 | Correlation is calculated as implemented in AveragerPairWeighted |
---|
59 | |
---|
60 | @return Pearson correlation. |
---|
61 | */ |
---|
62 | double score(void) const; |
---|
63 | |
---|
64 | /** |
---|
65 | The p-value is the probability of getting a correlation as |
---|
66 | large (or larger) as the observed value by random chance, when the true |
---|
67 | correlation is zero (and the data is Gaussian). |
---|
68 | |
---|
69 | P-value is calculated using function pearson_p_value(double, |
---|
70 | unsigned int) where degrees of freedom is calculated using n(void) in |
---|
71 | AveragerPairWeighted. |
---|
72 | |
---|
73 | @return one-sided p-value |
---|
74 | |
---|
75 | \relates PearsonCorrelation |
---|
76 | */ |
---|
77 | double p_value_one_sided() const; |
---|
78 | |
---|
79 | private: |
---|
80 | AveragerPairWeighted ap_; |
---|
81 | |
---|
82 | }; |
---|
83 | |
---|
84 | }}} // of namespace statistics, yat, and theplu |
---|
85 | |
---|
86 | #endif |
---|