class StorelessBivariateCovariance
extends java.lang.Object
This class is based on a paper written by Philippe Pébay:
Formulas for Robust, One-Pass Parallel Computation of Covariances and
Arbitrary-Order Statistical Moments, 2008, Technical Report SAND2008-6212,
Sandia National Laboratories. It computes the covariance for a pair of variables.
Use StorelessCovariance
to estimate an entire covariance matrix.
Note: This class is package private as it is only used internally in
the StorelessCovariance
class.
Modifier and Type | Field and Description |
---|---|
private boolean |
biasCorrected
flag for bias correction
|
private double |
covarianceNumerator
the running covariance estimate
|
private double |
meanX
the mean of variable x
|
private double |
meanY
the mean of variable y
|
private double |
n
number of observations
|
Constructor and Description |
---|
StorelessBivariateCovariance()
Create an empty
StorelessBivariateCovariance instance with
bias correction. |
StorelessBivariateCovariance(boolean biasCorrection)
Create an empty
StorelessBivariateCovariance instance. |
Modifier and Type | Method and Description |
---|---|
void |
append(StorelessBivariateCovariance cov)
Appends another bivariate covariance calculation to this.
|
double |
getN()
Returns the number of observations.
|
double |
getResult()
Return the current covariance estimate.
|
void |
increment(double x,
double y)
Update the covariance estimation with a pair of variables (x, y).
|
private double meanX
private double meanY
private double n
private double covarianceNumerator
private boolean biasCorrected
public StorelessBivariateCovariance()
StorelessBivariateCovariance
instance with
bias correction.public StorelessBivariateCovariance(boolean biasCorrection)
StorelessBivariateCovariance
instance.biasCorrection
- if true
the covariance estimate is corrected
for bias, i.e. n-1 in the denominator, otherwise there is no bias correction,
i.e. n in the denominator.public void increment(double x, double y)
x
- the x valuey
- the y valuepublic void append(StorelessBivariateCovariance cov)
increment(double, double)
operations in cov
directly on this.cov
- StorelessBivariateCovariance instance to append.public double getN()
public double getResult() throws NumberIsTooSmallException
NumberIsTooSmallException
- if the number of observations
is < 2Copyright (c) 2003-2016 Apache Software Foundation