Computes the covariance matrix in a window of incoming values.
Inspiration: http://rebcabin.github.io/blog/2013/01/22/covariance-matrices/
Methods defined:
Default constructor. The covariance values are set to 0. Data length defaults to 100.
_Scalar
-- the datatype you will use to input your values, e.g. double
or float
.
_Dimension
-- an int equal to the number of variables in this tracker. E.g. for storing
the x, y, and z values obtained from a 3-axis accelerometer, use _Dimension = 3
.
Adds the specified data point to this tracker. Example:
CovarianceTracker<float, 3> covtrack(100); Eigen::Matrix<float, 1, 3> datapoint; // datapoint is a 3-vector datapoint << 1.0, 2.0, 3.0; // datapoint is now <1.0, 2.0, 3.0> covtrack.addData(datapoint);
Adds the specified data point to this tracker. Asserts the size of point
is equal to _Dimension
! So only pass the correct number of arguments or
you will get a runtime error.
Receives a _Scalar
array to be used as a data point. If the input array
does not have a length _Dimension
, memory will be grabbed that does not
belong to the array, which will lead to undefined behavior.
Returns the fraction of the stored data matrix that is used.
Returns the mean vector of the values stored in this covariance tracker.
Calculate and return the covariance matrix. If no data or one datum has been inserted
into this tracker, returns a _Dimension
x _Dimension
matrix of zeros.
Returns the number of data that can be stored in this tracker. Unfortunately, there is
no way to change this value, so if you want to change it, you'll just have to initialize
a new CovarianceTracker
object.
Returns _Dimension
.
Returns the fraction of the data matrix that is used. (>= 0 and <= 1)