source: trunk/yat/statistics/Pearson.h

Last change on this file was 2992, checked in by Peter, 9 years ago

set svndigest:ignore proprty to reflect when files were initially copied from other file (and early history should be ignored). closes #750

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svndigest:ignore set to 776
File size: 2.8 KB
Line 
1#ifndef _theplu_yat_statistics_pearson_
2#define _theplu_yat_statistics_pearson_
3
4// $Id: Pearson.h 2992 2013-03-03 05:03:44Z 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 "Score.h"
28
29namespace theplu {
30namespace yat {
31namespace utility {
32  class VectorBase;
33}
34namespace statistics { 
35
36  ///
37  /// @brief Class for calculating Pearson correlation.
38  ///   
39 
40  class Pearson : public Score
41  {
42  public:
43    ///
44    /// @brief The default constructor.
45    ///
46    Pearson(bool absolute=true);
47
48    ///
49    /// @brief The destructor.
50    ///
51    virtual ~Pearson(void);
52         
53   
54    /**
55       \f$ \frac{\vert \sum_i(x_i-\bar{x})(y_i-\bar{y})\vert
56       }{\sqrt{\sum_i (x_i-\bar{x})^2\sum_i (x_i-\bar{x})^2}} \f$.
57       @return Pearson correlation, if absolute=true absolute value
58       of Pearson is used.
59    */
60    double score(const classifier::Target& target, 
61                 const utility::VectorBase& value) const;
62
63    /**
64       \f$ \frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert }
65       {\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}}
66       \f$, where \f$ m_x = \frac{\sum w_ix_i}{\sum w_i} \f$ and \f$
67       m_x = \frac{\sum w_ix_i}{\sum w_i} \f$. This expression is
68       chosen to get a correlation equal to unity when \a x and \a y
69       are equal. @return absolute value of weighted version of
70       Pearson correlation.
71    */
72    double score(const classifier::Target& target, 
73                 const classifier::DataLookupWeighted1D& value) const; 
74
75    /**
76       \f$ \frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert }
77       {\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}}
78       \f$, where \f$ m_x = \frac{\sum w_ix_i}{\sum w_i} \f$ and \f$
79       m_x = \frac{\sum w_ix_i}{\sum w_i} \f$. This expression is
80       chosen to get a correlation equal to unity when \a x and \a y
81       are equal. @return absolute value of weighted version of
82       Pearson correlation.
83    */
84    double score(const classifier::Target& target, 
85                 const utility::VectorBase& value,
86                 const utility::VectorBase& weight) const; 
87
88  };
89
90}}} // of namespace statistics, yat, and theplu
91
92#endif
Note: See TracBrowser for help on using the repository browser.