jsat.linear
Class MatrixStatistics
- java.lang.Object
-
- jsat.linear.MatrixStatistics
-
public class MatrixStatistics extends java.lang.ObjectThis class provides methods useful for statistical operations that involve matrices and vectors.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static VeccovarianceDiag(Vec means, DataSet dataset)Computes the weighted diagonal of the covariance matrix, which is the standard deviations of the columns of all values.static <V extends Vec>
VeccovarianceDiag(Vec means, java.util.List<V> dataset)Computes the diagonal of the covariance matrix, which is the standard deviations of the columns of all values.static voidcovarianceDiag(Vec means, Vec diag, DataSet dataset)Computes the weighted diagonal of the covariance matrix, which is the standard deviations of the columns of all values.static <V extends Vec>
voidcovarianceDiag(Vec means, Vec diag, java.util.List<V> dataset)Computes the diagonal of the covariance matrix, which is the standard deviations of the columns of all values.static MatrixcovarianceMatrix(Vec mean, DataSet dataSet)Computes the weighted covariance matrix of the data setstatic voidcovarianceMatrix(Vec mean, DataSet dataSet, Matrix covariance)Computes the weighted covariance matrix of the given data set.static voidcovarianceMatrix(Vec mean, DataSet dataSet, Matrix covariance, double sumOfWeights, double sumOfSquaredWeights)Computes the weighted covariance matrix of the given data set.static voidcovarianceMatrix(Vec mean, java.util.List<DataPoint> dataSet, Matrix covariance)Computes the weighted result for the covariance matrix of the given data set.static voidcovarianceMatrix(Vec mean, java.util.List<DataPoint> dataSet, Matrix covariance, double sumOfWeights, double sumOfSquaredWeights)Computes the weighted result for the covariance matrix of the given data set.static <V extends Vec>
MatrixcovarianceMatrix(Vec mean, java.util.List<V> dataSet)static <V extends Vec>
voidcovarianceMatrix(Vec mean, Matrix covariance, java.util.List<V> dataSet)static <V extends Vec>
voidcovarianceMatrix(Vec mean, Matrix covariance, java.util.List<V> dataSet, java.util.Collection<java.lang.Integer> subset)static <V extends Vec>
voidFastMCD(Vec mean, Matrix cov, java.util.List<V> dataset, boolean parallel)This algorithm implements the FastMCD algorithm for robustly estimating the mean and covariance of a dataset.static VecmeanVector(DataSet dataSet)Computes the weighted mean of the given data set.static <V extends Vec>
VecmeanVector(java.util.List<V> dataSet)Computes the mean of the given data set.static voidmeanVector(Vec mean, DataSet dataSet)Computes the weighted mean of the data setstatic <V extends Vec>
voidmeanVector(Vec mean, java.util.List<V> dataSet)Computes the mean of the given data set.static <V extends Vec>
voidmeanVector(Vec mean, java.util.List<V> dataSet, java.util.Collection<java.lang.Integer> subset)Computes the mean of the given data set.
-
-
-
Method Detail
-
meanVector
public static <V extends Vec> Vec meanVector(java.util.List<V> dataSet)
Computes the mean of the given data set.- Type Parameters:
V- the vector type- Parameters:
dataSet- the list of vectors to compute the mean of- Returns:
- the mean of the vectors
-
meanVector
public static Vec meanVector(DataSet dataSet)
Computes the weighted mean of the given data set.- Parameters:
dataSet- the dataset to compute the mean from- Returns:
- the mean of the numeric vectors in the data set
-
meanVector
public static <V extends Vec> void meanVector(Vec mean, java.util.List<V> dataSet)
Computes the mean of the given data set.- Parameters:
mean- the zeroed out vector to store the mean in. Its contents will be altereddataSet- the set of data points to compute the mean from
-
meanVector
public static <V extends Vec> void meanVector(Vec mean, java.util.List<V> dataSet, java.util.Collection<java.lang.Integer> subset)
Computes the mean of the given data set.- Type Parameters:
V-- Parameters:
mean- the zeroed out vector to store the mean in. Its contents will be altereddataSet- the set of data points to compute the mean fromsubset- the indecies of the points in dataSet to take the mean of
-
meanVector
public static void meanVector(Vec mean, DataSet dataSet)
Computes the weighted mean of the data set- Parameters:
mean- the zeroed out vector to store the mean in. Its contents will be altereddataSet- the set of data points to compute the mean from
-
covarianceMatrix
public static <V extends Vec> Matrix covarianceMatrix(Vec mean, java.util.List<V> dataSet)
-
covarianceMatrix
public static <V extends Vec> void covarianceMatrix(Vec mean, Matrix covariance, java.util.List<V> dataSet)
-
covarianceMatrix
public static <V extends Vec> void covarianceMatrix(Vec mean, Matrix covariance, java.util.List<V> dataSet, java.util.Collection<java.lang.Integer> subset)
-
covarianceMatrix
public static void covarianceMatrix(Vec mean, java.util.List<DataPoint> dataSet, Matrix covariance)
Computes the weighted result for the covariance matrix of the given data set. If all weights have the same value, the result will come out equivalent tocovarianceMatrix(jsat.linear.Vec, java.util.List)- Parameters:
mean- the mean of the distribution.dataSet- the set of data points that contain vectorscovariance- the zeroed matrix to store the result in. Its values will be altered.
-
covarianceMatrix
public static void covarianceMatrix(Vec mean, java.util.List<DataPoint> dataSet, Matrix covariance, double sumOfWeights, double sumOfSquaredWeights)
Computes the weighted result for the covariance matrix of the given data set. If all weights have the same value, the result will come out equivalent tocovarianceMatrix(jsat.linear.Vec, java.util.List)- Parameters:
mean- the mean of the distribution.dataSet- the set of data points that contain vectorscovariance- the zeroed matrix to store the result in. Its values will be altered.sumOfWeights- the sum of each weight in dataSetsumOfSquaredWeights- the sum of the squared weights in dataSet
-
covarianceMatrix
public static Matrix covarianceMatrix(Vec mean, DataSet dataSet)
Computes the weighted covariance matrix of the data set- Parameters:
mean- the mean of the data setdataSet- the dataset to compute the covariance of- Returns:
- the covariance matrix of the data set
-
covarianceMatrix
public static void covarianceMatrix(Vec mean, DataSet dataSet, Matrix covariance)
Computes the weighted covariance matrix of the given data set.- Parameters:
mean- the mean of the data setdataSet- the dataset to compute the covariance ofcovariance- the zeroed out matrix to store the result into
-
covarianceMatrix
public static void covarianceMatrix(Vec mean, DataSet dataSet, Matrix covariance, double sumOfWeights, double sumOfSquaredWeights)
Computes the weighted covariance matrix of the given data set. Superfluous calculations are avoided by having the call provide information.- Parameters:
mean- the mean of the data setdataSet- the dataset to compute the covariance ofcovariance- the zeroed out matrix to store the result intosumOfWeights- the sum of the weights for each data point in the datasetsumOfSquaredWeights- the sum of the squared weights for each data point in the data set
-
covarianceDiag
public static void covarianceDiag(Vec means, Vec diag, DataSet dataset)
Computes the weighted diagonal of the covariance matrix, which is the standard deviations of the columns of all values.- Parameters:
means- the already computed mean of the data setdiag- the zeroed out vector to store the diagonal in. Its contents will be altereddataset- the data set to compute the covariance diagonal from
-
covarianceDiag
public static Vec covarianceDiag(Vec means, DataSet dataset)
Computes the weighted diagonal of the covariance matrix, which is the standard deviations of the columns of all values.- Parameters:
means- the already computed mean of the data setdataset- the data set to compute the covariance diagonal from- Returns:
- the diagonal of the covariance matrix for the given data
-
covarianceDiag
public static <V extends Vec> void covarianceDiag(Vec means, Vec diag, java.util.List<V> dataset)
Computes the diagonal of the covariance matrix, which is the standard deviations of the columns of all values.- Type Parameters:
V- the type of the vector- Parameters:
means- the already computed mean of the data setdiag- the zeroed out vector to store the diagonal in. Its contents will be altereddataset- the data set to compute the covariance diagonal from
-
covarianceDiag
public static <V extends Vec> Vec covarianceDiag(Vec means, java.util.List<V> dataset)
Computes the diagonal of the covariance matrix, which is the standard deviations of the columns of all values.- Type Parameters:
V-- Parameters:
means- the already computed mean of the data setdataset- the data set to compute the covariance diagonal from- Returns:
- the diagonal of the covariance matrix for the given data
-
FastMCD
public static <V extends Vec> void FastMCD(Vec mean, Matrix cov, java.util.List<V> dataset, boolean parallel)
This algorithm implements the FastMCD algorithm for robustly estimating the mean and covariance of a dataset. Computational complexity increases linearly with the sample sizen, but cubically with the dimension sized.
See: Rousseeuw, P. J., & Driessen, K. Van. (1999). A Fast Algorithm for the Minimum Covariance Determinant Estimator. Technometrics, 41(3), 212–223. http://doi.org/10.2307/1270566- Type Parameters:
V-- Parameters:
mean- the location to store the estimated mean, values will be overwrittencov- the location to store the estimated covariance, values will be overwrittendataset- the set of data points to estimate the mean and covariance ofparallel-trueif multiple cores should be used for estimation,falsefor single thread.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG