java.lang.Object
imagingbook.common.math.Statistics
This class defines static methods for statistical calculations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[][]
conditionCovarianceMatrix
(double[][] cov, double minDiagVal) Conditions the supplied covariance matrix by enforcing positive eigenvalues.static RealMatrix
conditionCovarianceMatrix
(RealMatrix cov, double minDiagVal) Conditions the supplied covariance matrix by enforcing positive eigenvalues.static double[][]
covarianceMatrix
(double[][] samples) Calculates the covariance matrix for a sequence of sample vectors.static double[][]
covarianceMatrix
(double[][] samples, boolean biasCorrect) Calculates the covariance matrix for a sequence of sample vectors.static double[]
meanVector
(double[][] samples) Calculates the mean vector for a sequence of sample vectors.
-
Method Details
-
meanVector
Calculates the mean vector for a sequence of sample vectors.- Parameters:
samples
- a 2D array of m-dimensional vectors (double[n][m]})- Returns:
- the mean vector for the sample data (of length m)
-
covarianceMatrix
Calculates the covariance matrix for a sequence of sample vectors. Takes a sequence of n data samples, each of dimension m. The data elementsamples[i][j]
refers to the j-th component of sample i. No statistical bias correction is applied. UsesCovariance
from Apache Commons Math.- Parameters:
samples
- a 2D array of m-dimensional vectors (double[n][m]})- Returns:
- the covariance matrix for the sample data (of dimension m x m)
- See Also:
-
covarianceMatrix
Calculates the covariance matrix for a sequence of sample vectors. Takes a sequence of n data samples, each of dimension m. The data elementsamples[i][j]
refers to the j-th component of sample i. Statistical bias correction is optionally applied. UsesCovariance
from Apache Commons Math.- Parameters:
samples
- a 2D array of m-dimensional vectors (double[n][m]).biasCorrect
- iftrue
, statistical bias correction is applied.- Returns:
- the covariance matrix for the sample data (of dimension m x m).
- See Also:
-
conditionCovarianceMatrix
Conditions the supplied covariance matrix by enforcing positive eigenvalues.- Parameters:
cov
- original covariance matrixminDiagVal
- the minimum positive value of diagonal elements- Returns:
- conditioned covariance matrix
-
conditionCovarianceMatrix
Conditions the supplied covariance matrix by enforcing positive eigenvalues.- Parameters:
cov
- original covariance matrixminDiagVal
- the minimum positive value of diagonal elements- Returns:
- conditioned covariance matrix
-