public class CovarianceMatrix
extends java.lang.Object
DatabaseUtil
for
easier to use APIs.
For use in algorithms, it is more appropriate to use
StandardCovarianceMatrixBuilder
since this class can be overridden with a
stabilized covariance matrix builder!Modifier and Type | Field and Description |
---|---|
(package private) double[][] |
elements
The covariance matrix.
|
static java.lang.String |
ERR_TOO_LITTLE_WEIGHT
Error message reported when too little data (weight <= 1) in matrix.
|
(package private) double[] |
mean
The means.
|
(package private) double[] |
nmea
Temporary storage, to avoid reallocations.
|
protected double |
wsum
The current weight.
|
Constructor and Description |
---|
CovarianceMatrix(int dim)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
double[][] |
destroyToPopulationMatrix()
Obtain the covariance matrix according to the population statistics: n
degrees of freedom.
|
double[][] |
destroyToSampleMatrix()
Obtain the covariance matrix according to the sample statistics: (n-1)
degrees of freedom.
|
int |
getDimensionality()
Get the matrix dimensionality.
|
double[] |
getMeanVector()
Get the mean as vector.
|
<F extends NumberVector> |
getMeanVector(Relation<? extends F> relation)
Get the mean as vector.
|
double |
getWeight()
Get the weight sum, to test whether the covariance matrix can be
materialized.
|
static CovarianceMatrix |
make(Relation<? extends NumberVector> relation)
Static Constructor from a full relation.
|
static CovarianceMatrix |
make(Relation<? extends NumberVector> relation,
DBIDs ids)
Static Constructor from a full relation.
|
double[][] |
makePopulationMatrix()
Obtain the covariance matrix according to the population statistics: n
degrees of freedom.
|
double[][] |
makeSampleMatrix()
Obtain the covariance matrix according to the sample statistics: (n-1)
degrees of freedom.
|
void |
put(double[] val)
Add a single value with weight 1.0.
|
void |
put(double[] val,
double weight)
Add data with a given weight.
|
void |
put(NumberVector val)
Add a single value with weight 1.0.
|
void |
put(NumberVector val,
double weight)
Add data with a given weight.
|
void |
reset()
Reset the covariance matrix.
|
public static final java.lang.String ERR_TOO_LITTLE_WEIGHT
double[] mean
double[][] elements
double[] nmea
protected double wsum
public CovarianceMatrix(int dim)
dim
- Dimensionalitypublic int getDimensionality()
public void put(double[] val)
val
- Valuepublic void put(double[] val, double weight)
val
- dataweight
- weightpublic void put(NumberVector val)
val
- Valuepublic void put(NumberVector val, double weight)
val
- dataweight
- weightpublic double getWeight()
public double[] getMeanVector()
public <F extends NumberVector> F getMeanVector(Relation<? extends F> relation)
F
- vector typerelation
- Data relationpublic double[][] makeSampleMatrix()
destroyToSampleMatrix()
if you do not need further
updates.public double[][] makePopulationMatrix()
destroyToPopulationMatrix()
if you do not need further
updates.public double[][] destroyToSampleMatrix()
makeSampleMatrix()
if
you want to perform further updates.public double[][] destroyToPopulationMatrix()
makePopulationMatrix()
if
you want to perform further updates.public void reset()
public static CovarianceMatrix make(Relation<? extends NumberVector> relation)
relation
- Relation to use.public static CovarianceMatrix make(Relation<? extends NumberVector> relation, DBIDs ids)
relation
- Relation to use.ids
- IDs to addCopyright © 2019 ELKI Development Team. License information.