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

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

merge patch release 0.4.2 to trunk. Delta 0.4.2-0.4.1

  • 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 1437 2008-08-25 17:55:00Z 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 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 2 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 this program; if not, write to the Free Software
26  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27  02111-1307, USA.
28*/
29
30#include "AveragerPairWeighted.h"
31
32namespace theplu {
33namespace yat {
34namespace statistics {
35
36  ///
37  /// @brief Class for calculating Pearson correlation.
38  ///
39  class PearsonCorrelation
40  {
41  public:
42    ///
43    /// @brief The default constructor.
44    ///
45    PearsonCorrelation(void);
46   
47    ///
48    /// @brief The destructor.
49    ///
50    virtual ~PearsonCorrelation(void);
51   
52   
53    /**
54       Adding a data value to PearsonCorrelation.
55    */
56    void add(double value, bool target, double weight=1.0);
57
58    /**
59       \brief correlation
60
61       Correlation is calculated as implemented in AveragerPairWeighted
62
63       @return Pearson correlation.
64    */
65    double score(void) const;
66   
67    /**
68       The p-value is the probability of getting a correlation as
69       large (or larger) as the observed value by random chance, when the true
70       correlation is zero (and the data is Gaussian).
71       
72       P-value is calculated using function pearson_p_value(double,
73       unsigned int) where degrees of freedom is calculated using n(void) in
74       AveragerPairWeighted.
75
76       @return one-sided p-value
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.