public class CovarianceMatrix extends Object
DatabaseUtil
for
easier to use APIs.
For use in algorithms, it is more appropriate to use
StandardCovarianceMatrixBuilder
since this class can be overriden with a stabilized covariance matrix builder!Modifier and Type | Field and Description |
---|---|
(package private) double[][] |
elements
The covariance 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 |
---|---|
Matrix |
destroyToNaiveMatrix()
Obtain the covariance matrix according to the population statistics: n
degrees of freedom.
|
Matrix |
destroyToSampleMatrix()
Obtain the covariance matrix according to the sample statistics: (n-1)
degrees of freedom.
|
Vector |
getMeanVector()
Get the mean as vector.
|
<F extends NumberVector<? extends F,?>> |
getMeanVector(Relation<? extends F> relation)
Get the mean as vector.
|
static CovarianceMatrix |
make(Matrix mat)
Static Constructor.
|
static CovarianceMatrix |
make(Relation<? extends NumberVector<?,?>> relation)
Static Constructor from a full relation.
|
static CovarianceMatrix |
make(Relation<? extends NumberVector<?,?>> relation,
Iterable<DBID> ids)
Static Constructor from a full relation.
|
Matrix |
makeNaiveMatrix()
Obtain the covariance matrix according to the population statistics: n
degrees of freedom.
|
Matrix |
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 |
put(Vector val)
Add a single value with weight 1.0
|
void |
put(Vector val,
double weight)
Add data with a given weight.
|
double[] mean
double[][] elements
double[] nmea
protected double wsum
public CovarianceMatrix(int dim)
dim
- Dimensionalitypublic void put(double[] val)
val
- Valuepublic void put(double[] val, double weight)
val
- dataweight
- weightpublic final void put(Vector val)
val
- Valuepublic final void put(Vector val, double weight)
val
- dataweight
- weightpublic void put(NumberVector<?,?> val)
val
- Valuepublic void put(NumberVector<?,?> val, double weight)
val
- dataweight
- weightpublic Vector getMeanVector()
public <F extends NumberVector<? extends F,?>> F getMeanVector(Relation<? extends F> relation)
public Matrix makeSampleMatrix()
destroyToSampleMatrix()
if you do not need further
updates.public Matrix makeNaiveMatrix()
destroyToNaiveMatrix()
if you do not need further
updates.public Matrix destroyToSampleMatrix()
makeSampleMatrix()
if
you want to perform further updates.public Matrix destroyToNaiveMatrix()
makeNaiveMatrix()
if
you want to perform further updates.public static CovarianceMatrix make(Matrix mat)
mat
- Matrix to use the columns ofpublic static CovarianceMatrix make(Relation<? extends NumberVector<?,?>> relation)
relation
- Relation to use.public static CovarianceMatrix make(Relation<? extends NumberVector<?,?>> relation, Iterable<DBID> ids)
relation
- Relation to use.ids
- IDs to add