public class StorelessCovariance extends Covariance
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.
Note: the underlying covariance matrix is symmetric, thus only the upper triangular part of the matrix is stored and updated each increment.
Constructor | Description |
---|---|
StorelessCovariance(int dim) |
Create a bias corrected covariance matrix with a given dimension.
|
StorelessCovariance(int dim,
boolean biasCorrected) |
Create a covariance matrix with a given number of rows and columns and the
indicated bias correction.
|
Modifier and Type | Method | Description |
---|---|---|
void |
append(StorelessCovariance sc) |
Appends
sc to this, effectively aggregating the computations in sc
with this. |
double |
getCovariance(int xIndex,
int yIndex) |
Get the covariance for an individual element of the covariance matrix.
|
RealMatrix |
getCovarianceMatrix() |
Returns the covariance matrix
|
double[][] |
getData() |
Return the covariance matrix as two-dimensional array.
|
int |
getN() |
This
Covariance method is not supported by a StorelessCovariance ,
since the number of bivariate observations does not have to be the same for different
pairs of covariates - i.e., N as defined in Covariance.getN() is undefined. |
void |
increment(double[] data) |
Increment the covariance matrix with one row of data.
|
computeCovarianceMatrix, computeCovarianceMatrix, computeCovarianceMatrix, computeCovarianceMatrix, covariance, covariance
public StorelessCovariance(int dim)
dim
- the dimension of the square covariance matrixpublic StorelessCovariance(int dim, boolean biasCorrected)
dim
- the dimension of the covariance matrixbiasCorrected
- 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 double getCovariance(int xIndex, int yIndex) throws MathIllegalArgumentException
xIndex
- row index in the covariance matrixyIndex
- column index in the covariance matrixMathIllegalArgumentException
- if the number of observations
in the cell is < 2public void increment(double[] data) throws MathIllegalArgumentException
data
- array representing one row of data.MathIllegalArgumentException
- if the length of rowData
does not match with the covariance matrixpublic void append(StorelessCovariance sc) throws MathIllegalArgumentException
sc
to this, effectively aggregating the computations in sc
with this. After invoking this method, covariances returned should be close
to what would have been obtained by performing all of the increment(double[])
operations in sc
directly on this.sc
- externally computed StorelessCovariance to add to thisMathIllegalArgumentException
- if the dimension of sc does not match thispublic RealMatrix getCovarianceMatrix() throws MathIllegalArgumentException
getCovarianceMatrix
in class Covariance
MathIllegalArgumentException
- if the number of observations
in a cell is < 2public double[][] getData() throws MathIllegalArgumentException
MathIllegalArgumentException
- if the number of observations
for a cell is < 2public int getN() throws MathRuntimeException
Covariance
method is not supported by a StorelessCovariance
,
since the number of bivariate observations does not have to be the same for different
pairs of covariates - i.e., N as defined in Covariance.getN()
is undefined.getN
in class Covariance
MathRuntimeException
MathRuntimeException
- in all casesCopyright © 2016–2018 Hipparchus.org. All rights reserved.