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.
| Modifier and Type | Field and Description |
|---|---|
| private StorelessBivariateCovariance[] | covMatrix
the square covariance matrix (upper triangular part) |
| private int | dimension
dimension of the square covariance matrix |
| Access | Constructor and Description |
|---|---|
| public | StorelessCovariance(final int
the dimension of the square covariance matrix dim)Create a bias corrected covariance matrix with a given dimension. |
| public | StorelessCovariance(final int
the dimension of the covariance matrix dim, final boolean if biasCorrected)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.Create a covariance matrix with a given number of rows and columns and the indicated bias correction. |
| Modifier and Type | Method and Description |
|---|---|
| public void | append(StorelessCovariance
externally computed StorelessCovariance to add to this sc)Appends |
| public double | Returns: the covariance of the given elementrow index in the covariance matrix xIndex, final int column index in the covariance matrix yIndex)Get the covariance for an individual element of the covariance matrix. |
| public RealMatrix | getCovarianceMatrix()
Overrides org. Returns the covariance matrix |
| public double[][] | Returns: a two-dimensional double array of covariance valuesReturn the covariance matrix as two-dimensional array. |
| private StorelessBivariateCovariance | Returns: theStorelessBivariateCovariance element at the given indexthe row index i, final int the column index j)Gets the element at index (i, j) from the covariance matrix |
| public int | Returns: nothing as this implementation always throws aMathUnsupportedOperationExceptionOverrides org. This |
| public void | increment(final double[]
array representing one row of data. data)Increment the covariance matrix with one row of data. |
| private int | Returns: the corresponding index in the matrix arraythe row index i, final int the column index j)Returns the index (i, j) translated into the one-dimensional array used to store the upper triangular part of the symmetric covariance matrix. |
| private void | initializeMatrix(final boolean
if the covariance estimate shall be corrected for bias biasCorrected)Initialize the internal two-dimensional array of
|
| private void | setElement(final int
the row index i, final int the column index j, final StorelessBivariateCovariance the cov)StorelessBivariateCovariance element to be setSets the covariance element at index (i, j) in the covariance matrix |
| covMatrix | back to summary |
|---|---|
| private StorelessBivariateCovariance[] covMatrix the square covariance matrix (upper triangular part) | |
| dimension | back to summary |
|---|---|
| private int dimension dimension of the square covariance matrix | |
| StorelessCovariance | back to summary |
|---|---|
| public StorelessCovariance(final int dim) Create a bias corrected covariance matrix with a given dimension.
| |
| StorelessCovariance | back to summary |
|---|---|
| public StorelessCovariance(final int dim, final boolean biasCorrected) Create a covariance matrix with a given number of rows and columns and the indicated bias correction.
| |
| append | back to summary |
|---|---|
| public void append(StorelessCovariance sc) throws DimensionMismatchException Appends
| |
| getCovariance | back to summary |
|---|---|
| public double getCovariance(final int xIndex, final int yIndex) throws NumberIsTooSmallException Get the covariance for an individual element of the covariance matrix.
| |
| getCovarianceMatrix | back to summary |
|---|---|
| public RealMatrix getCovarianceMatrix() throws NumberIsTooSmallException Overrides org. Doc from org. Returns the covariance matrix
| |
| getData | back to summary |
|---|---|
| public double[][] getData() throws NumberIsTooSmallException Return the covariance matrix as two-dimensional array.
| |
| getElement | back to summary |
|---|---|
| private StorelessBivariateCovariance getElement(final int i, final int j) Gets the element at index (i, j) from the covariance matrix
| |
| getN | back to summary |
|---|---|
| public int getN() throws MathUnsupportedOperationException Overrides org. This
| |
| increment | back to summary |
|---|---|
| public void increment(final double[] data) throws DimensionMismatchException Increment the covariance matrix with one row of data.
| |
| indexOf | back to summary |
|---|---|
| private int indexOf(final int i, final int j) Returns the index (i, j) translated into the one-dimensional array used to store the upper triangular part of the symmetric covariance matrix.
| |
| initializeMatrix | back to summary |
|---|---|
| private void initializeMatrix(final boolean biasCorrected) Initialize the internal two-dimensional array of
| |
| setElement | back to summary |
|---|---|
| private void setElement(final int i, final int j, final StorelessBivariateCovariance cov) Sets the covariance element at index (i, j) in the covariance matrix
| |