source: trunk/yat/statistics/PearsonCorrelation.h @ 2119

Last change on this file since 2119 was 2119, checked in by Peter, 12 years ago

converted files to utf-8. fixes #577

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1#ifndef _theplu_yat_statistics_pearson_correlation_
2#define _theplu_yat_statistics_pearson_correlation_
3
4// $Id: PearsonCorrelation.h 2119 2009-12-12 23:11:43Z 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  Copyright (C) 2009 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 "AveragerPairWeighted.h"
29
30namespace theplu {
31namespace yat {
32namespace statistics {
33
34  ///
35  /// @brief Class for calculating Pearson correlation.
36  ///
37  class PearsonCorrelation
38  {
39  public:
40    ///
41    /// @brief The default constructor.
42    ///
43    PearsonCorrelation(void);
44   
45    ///
46    /// @brief The destructor.
47    ///
48    virtual ~PearsonCorrelation(void);
49   
50   
51    /**
52       Adding a data value to PearsonCorrelation.
53    */
54    void add(double value, bool target, double weight=1.0);
55
56    /**
57       \brief correlation
58
59       Correlation is calculated as implemented in AveragerPairWeighted
60
61       @return Pearson correlation.
62    */
63    double score(void) const;
64   
65    /**
66       The p-value is the probability of getting a correlation as
67       large (or larger) as the observed value by random chance, when the true
68       correlation is zero (and the data is Gaussian).
69       
70       P-value is calculated using function pearson_p_value(double,
71       unsigned int) where degrees of freedom is calculated using n(void) in
72       AveragerPairWeighted.
73
74       @return one-sided p-value
75
76       \relates PearsonCorrelation
77    */
78    double p_value_one_sided() const;
79   
80  private:
81    AveragerPairWeighted ap_;
82   
83  };
84 
85}}} // of namespace statistics, yat, and theplu
86
87#endif
Note: See TracBrowser for help on using the repository browser.