# source:trunk/c++_tools/statistics/Pearson.h@623

Last change on this file since 623 was 623, checked in by Peter, 17 years ago

fixes #112 and refs #123 added overloaded function score taking Target and DataLookupWeighted1D, which is needed for InputRanker?.

• Property svn:eol-style set to native
• Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line
1#ifndef _theplu_statistics_pearson_
2#define _theplu_statistics_pearson_
3
4// $Id: Pearson.h 623 2006-09-05 02:13:12Z peter$
5
6#include <c++_tools/statistics/Score.h>
7
8namespace theplu {
9namespace utility {
10  class vector;
11}
12namespace classifier {
13  class VectorAbstract;
14}
15namespace statistics {
16
17  ///
18  /// Class for calculating Pearson correlation.
19  ///
20
21  class Pearson : public Score
22  {
23
24  public:
25    ///
26    /// Default Constructor.
27    ///
28    Pearson(bool absolute=true);
29
30    ///
31    /// Destructor
32    ///
33    virtual ~Pearson(void) {};
34
35
36    ///
37    /// \f$\frac{\vert \sum_i(x_i-\bar{x})(y_i-\bar{y})\vert 38 /// }{\sqrt{\sum_i (x_i-\bar{x})^2\sum_i (x_i-\bar{x})^2}} \f$.
39    /// @return Pearson correlation, if absolute=true absolute value
40    /// of Pearson is used.
41    ///
42    double score(const classifier::Target& target,
43                 const utility::vector& value);
44
45    ///
46    /// \f$\frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert } 47 /// {\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}} 48 /// \f$, where \f$m_x = \frac{\sum w_ix_i}{\sum w_i} \f$ and \f$49 /// m_x = \frac{\sum w_ix_i}{\sum w_i} \f$. This expression is
50    /// chosen to get a correlation equal to unity when \a x and \a y
51    /// are equal. @return absolute value of weighted version of
52    /// Pearson correlation.
53    ///
54    double score(const classifier::Target& target,
55                 const classifier::DataLookupWeighted1D& value);
56
57    ///
58    /// \f$\frac{\vert \sum_iw^2_i(x_i-\bar{x})(y_i-\bar{y})\vert } 59 /// {\sqrt{\sum_iw^2_i(x_i-\bar{x})^2\sum_iw^2_i(y_i-\bar{y})^2}} 60 /// \f$, where \f$m_x = \frac{\sum w_ix_i}{\sum w_i} \f$ and \f$61 /// m_x = \frac{\sum w_ix_i}{\sum w_i} \f$. This expression is
62    /// chosen to get a correlation equal to unity when \a x and \a y
63    /// are equal. @return absolute value of weighted version of
64    /// Pearson correlation.
65    ///
66    double score(const classifier::Target& target,
67                 const utility::vector& value,
68                 const utility::vector& weight);
69
70    ///
71    /// The p-value is the probability of getting a correlation as
72    /// large as the observed value by random chance, when the true
73    /// correlation is zero (and the data is Gaussian). Note that this
74    /// function can only be used together with the unweighted
75    /// score. @return two-sided p-value
76    ///
77    double p_value() const;
78
79  private:
80    double r_;
81    int nof_samples_;
82
83
84    //    void centralize(utility::vector&, const utility::vector&);
85  };
86
87}} // of namespace statistics and namespace theplu
88
89#endif
90
Note: See TracBrowser for help on using the repository browser.