1 | #ifndef _theplu_yat_statistics_pearson_ |
---|
2 | #define _theplu_yat_statistics_pearson_ |
---|
3 | |
---|
4 | // $Id: Pearson.h 1275 2008-04-11 06:10:12Z jari $ |
---|
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 Jari Häkkinen, Peter Johansson |
---|
10 | Copyright (C) 2008 Peter Johansson |
---|
11 | |
---|
12 | This file is part of the yat library, http://trac.thep.lu.se/yat |
---|
13 | |
---|
14 | The yat library is free software; you can redistribute it and/or |
---|
15 | modify it under the terms of the GNU General Public License as |
---|
16 | published by the Free Software Foundation; either version 2 of the |
---|
17 | License, or (at your option) any later version. |
---|
18 | |
---|
19 | The yat library is distributed in the hope that it will be useful, |
---|
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
22 | General Public License for more details. |
---|
23 | |
---|
24 | You should have received a copy of the GNU General Public License |
---|
25 | along with this program; if not, write to the Free Software |
---|
26 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
27 | 02111-1307, USA. |
---|
28 | */ |
---|
29 | |
---|
30 | #include "Score.h" |
---|
31 | |
---|
32 | namespace theplu { |
---|
33 | namespace yat { |
---|
34 | namespace utility { |
---|
35 | class VectorBase; |
---|
36 | } |
---|
37 | namespace statistics { |
---|
38 | |
---|
39 | /// |
---|
40 | /// @brief Class for calculating Pearson correlation. |
---|
41 | /// |
---|
42 | |
---|
43 | class Pearson : public Score |
---|
44 | { |
---|
45 | public: |
---|
46 | /// |
---|
47 | /// @brief The default constructor. |
---|
48 | /// |
---|
49 | Pearson(bool absolute=true); |
---|
50 | |
---|
51 | /// |
---|
52 | /// @brief The destructor. |
---|
53 | /// |
---|
54 | virtual ~Pearson(void); |
---|
55 | |
---|
56 | |
---|
57 | /** |
---|
58 | \f$ \frac{\vert \sum_i(x_i-\bar{x})(y_i-\bar{y})\vert |
---|
59 | }{\sqrt{\sum_i (x_i-\bar{x})^2\sum_i (x_i-\bar{x})^2}} \f$. |
---|
60 | @return Pearson correlation, if absolute=true absolute value |
---|
61 | of Pearson is used. |
---|
62 | */ |
---|
63 | double score(const classifier::Target& target, |
---|
64 | const utility::VectorBase& value) const; |
---|
65 | |
---|
66 | /** |
---|
67 | \f$ \frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert } |
---|
68 | {\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}} |
---|
69 | \f$, where \f$ m_x = \frac{\sum w_ix_i}{\sum w_i} \f$ and \f$ |
---|
70 | m_x = \frac{\sum w_ix_i}{\sum w_i} \f$. This expression is |
---|
71 | chosen to get a correlation equal to unity when \a x and \a y |
---|
72 | are equal. @return absolute value of weighted version of |
---|
73 | Pearson correlation. |
---|
74 | */ |
---|
75 | double score(const classifier::Target& target, |
---|
76 | const classifier::DataLookupWeighted1D& value) const; |
---|
77 | |
---|
78 | /** |
---|
79 | \f$ \frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert } |
---|
80 | {\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}} |
---|
81 | \f$, where \f$ m_x = \frac{\sum w_ix_i}{\sum w_i} \f$ and \f$ |
---|
82 | m_x = \frac{\sum w_ix_i}{\sum w_i} \f$. This expression is |
---|
83 | chosen to get a correlation equal to unity when \a x and \a y |
---|
84 | are equal. @return absolute value of weighted version of |
---|
85 | Pearson correlation. |
---|
86 | */ |
---|
87 | double score(const classifier::Target& target, |
---|
88 | const utility::VectorBase& value, |
---|
89 | const utility::VectorBase& weight) const; |
---|
90 | |
---|
91 | }; |
---|
92 | |
---|
93 | }}} // of namespace statistics, yat, and theplu |
---|
94 | |
---|
95 | #endif |
---|