java.lang.Object
org.bzdev.math.stats.CovarianceMatrix
org.bzdev.math.stats.CovarianceMatrix.Sample
- Enclosing class:
- CovarianceMatrix
Class to compute a sample covariance matrix.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bzdev.math.stats.CovarianceMatrix
CovarianceMatrix.Population, CovarianceMatrix.Sample
-
Field Summary
Fields inherited from class org.bzdev.math.stats.CovarianceMatrix
count
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected double
The elements of the variance array that is computed will be scaled by a correction factor.Methods inherited from class org.bzdev.math.stats.CovarianceMatrix
add, addsComplete, getCorrelationMatrix, getCorrelationMatrix, getDimension, getMatrix, getMeans
-
Constructor Details
-
Sample
public Sample(int n) Constructor. The methodCovarianceMatrix.add(double[])
must be called repeatedly to provide the dataset used to compute the covariance matrix and mean array.- Parameters:
n
- the number of variables
-
Sample
public Sample(double[][] arrays, int n) Constructor given an array containing the initial dataset used to compute a covariance matrix. This dataset can be extended using theCovarianceMatrix.add(double[])
method.- Parameters:
arrays
- an array, each component of which is an array containing the values for n variablesn
- the number of variables
-
-
Method Details
-
getCorrection
protected double getCorrection()Description copied from class:CovarianceMatrix
The elements of the variance array that is computed will be scaled by a correction factor. This factor should be 1.0 when the dataset represents a total population. For a sample of a population, the factor is m/(m-1) where m is the sample size.The subclasses
CovarianceMatrix.Sample
andCovarianceMatrix.Population
provide suitable implementations of this method for those cases.- Specified by:
getCorrection
in classCovarianceMatrix
- Returns:
- the correction factor; Double.NaN if the factor cannot be computed due to too few entries
-