Package mdp :: Package utils :: Class DelayCovarianceMatrix
[hide private]
[frames] | no frames]

Class DelayCovarianceMatrix


This class stores an empirical covariance matrix between the signal and time delayed signal that can be updated incrementally.

Note that the internal sum is a standard __add__ operation. We are not using any of the fancy sum algorithms to avoid round off errors when adding many numbers. If you want to contribute a CovarianceMatrix class that uses such algorithms we would be happy to include it in MDP. For a start see the Python recipe by Raymond Hettinger at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/393090 For a review about floating point arithmetic and its pitfalls see http://docs.sun.com/source/806-3568/ncg_goldberg.html

Instance Methods [hide private]
 
__init__(self, dt, dtype=None, bias=False)
dt is the time delay. If dt==0, DelayCovarianceMatrix equals CovarianceMatrix. If dtype is not defined, it will be inherited from the first data bunch received by 'update'. All the matrices in this class are set up with the given dtype and no upcast is possible. If bias is True, the covariance matrix is normalized by dividing by T instead of the usual T-1.
 
_init_internals(self, x)
Inits some internals structures.
 
fix(self, A=None)
The collected data is adjusted to compute the covariance matrix of the signal x(1)...x(N-dt) and the delayed signal x(dt)...x(N), which is defined as <(x(t)-<x(t)>)*(x(t+dt)-<x(t+dt)>)> . The function returns a tuple containing the covariance matrix, the average <x(t)> over the first N-dt points, the average of the delayed signal <x(t+dt)> and the number of observations. The internal data is then reset to a zero-state.
 
update(self, x)
Update internal structures.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, dt, dtype=None, bias=False)
(Constructor)

 
dt is the time delay. If dt==0, DelayCovarianceMatrix equals CovarianceMatrix. If dtype is not defined, it will be inherited from the first data bunch received by 'update'. All the matrices in this class are set up with the given dtype and no upcast is possible. If bias is True, the covariance matrix is normalized by dividing by T instead of the usual T-1.
Overrides: object.__init__

_init_internals(self, x)

 
Inits some internals structures. The reason this is not done in
the constructor is that we want to be able to derive the input
dimension and the dtype directly from the data this class receives.

fix(self, A=None)

 

The collected data is adjusted to compute the covariance matrix of the signal x(1)...x(N-dt) and the delayed signal x(dt)...x(N), which is defined as <(x(t)-<x(t)>)*(x(t+dt)-<x(t+dt)>)> . The function returns a tuple containing the covariance matrix, the average <x(t)> over the first N-dt points, the average of the delayed signal <x(t+dt)> and the number of observations. The internal data is then reset to a zero-state.

If A is defined, the covariance matrix is transformed by the linear transformation Ax . E.g. to whiten the data, A is the whitening matrix.

update(self, x)

 
Update internal structures.