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

Last change on this file since 1271 was 1271, checked in by Peter, 13 years ago

replaced u_int with unsigned int or size_t

  • 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 1271 2008-04-09 16:11:07Z peter $
5
6/*
7  Copyright (C) 2004, 2005 Peter Johansson
8  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér, Peter Johansson
9  Copyright (C) 2007, 2008 Peter Johansson
10
11  This file is part of the yat library, http://trac.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 2 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 this program; if not, write to the Free Software
25  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26  02111-1307, USA.
27*/
28
29#include "AveragerPairWeighted.h"
30
31namespace theplu {
32namespace yat {
33namespace statistics {
34
35  ///
36  /// @brief Class for calculating Pearson correlation.
37  ///
38  class PearsonCorrelation
39  {
40  public:
41    ///
42    /// @brief The default constructor.
43    ///
44    PearsonCorrelation(void);
45   
46    ///
47    /// @brief The destructor.
48    ///
49    virtual ~PearsonCorrelation(void);
50   
51   
52    /**
53       Adding a data value to PearsonCorrelation.
54    */
55    void add(double value, bool target, double weight=1.0);
56
57    /**
58       \brief correlation
59
60       Correlation is calculated as implemented in AveragerPairWeighted
61
62       @return Pearson correlation.
63    */
64    double score(void) const;
65   
66    /**
67       The p-value is the probability of getting a correlation as
68       large (or larger) as the observed value by random chance, when the true
69       correlation is zero (and the data is Gaussian).
70       
71       P-value is calculated using function pearson_p_value(double,
72       unsigned int) where degrees of freedom is calculated using n(void) in
73       AveragerPairWeighted.
74
75       @return one-sided p-value
76    */
77    double p_value_one_sided() const;
78   
79  private:
80    AveragerPairWeighted ap_;
81   
82  };
83 
84}}} // of namespace statistics, yat, and theplu
85
86#endif
Note: See TracBrowser for help on using the repository browser.