source: trunk/yat/statistics/Pearson.h @ 1703

Last change on this file since 1703 was 1487, checked in by Jari Häkkinen, 13 years ago

Addresses #436. GPL license copy reference should also be updated.

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