# source:branches/peters_vector/lib/statistics/Pearson.h@469

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

non compiling checking before revision after design meeting

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