#ifndef _theplu_yat_statistics_pearson_correlation_
#define _theplu_yat_statistics_pearson_correlation_
// $Id: PearsonCorrelation.h 1275 2008-04-11 06:10:12Z jari $
/*
Copyright (C) 2004, 2005 Peter Johansson
Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
Copyright (C) 2007 Jari Häkkinen, Peter Johansson
Copyright (C) 2008 Peter Johansson
This file is part of the yat library, http://trac.thep.lu.se/yat
The yat library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The yat library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#include "AveragerPairWeighted.h"
namespace theplu {
namespace yat {
namespace statistics {
///
/// @brief Class for calculating Pearson correlation.
///
class PearsonCorrelation
{
public:
///
/// @brief The default constructor.
///
PearsonCorrelation(void);
///
/// @brief The destructor.
///
virtual ~PearsonCorrelation(void);
/**
Adding a data value to PearsonCorrelation.
*/
void add(double value, bool target, double weight=1.0);
/**
\brief correlation
Correlation is calculated as implemented in AveragerPairWeighted
@return Pearson correlation.
*/
double score(void) const;
/**
The p-value is the probability of getting a correlation as
large (or larger) as the observed value by random chance, when the true
correlation is zero (and the data is Gaussian).
P-value is calculated using function pearson_p_value(double,
unsigned int) where degrees of freedom is calculated using n(void) in
AveragerPairWeighted.
@return one-sided p-value
*/
double p_value_one_sided() const;
private:
AveragerPairWeighted ap_;
};
}}} // of namespace statistics, yat, and theplu
#endif