function covars

deeptime.covariance.covars(X, Y, remove_mean=False, modify_data=False, symmetrize=False, weights=None, sparse_mode='auto', sparse_tol=0.0)

Computes the covariance and cross-covariance matrix of X and Y.

If symmetrize is False, computes

\[\begin{aligned} C_{XX} &= X^{\top} X \\ C_{XY} &= X^{\top} Y \end{aligned}\]

If symmetrize is True, computes

\[\begin{aligned} C_{XX} &= \frac{1}{2} (X^{\top} X + Y^{\top} Y)\\ C_{XY} &= \frac{1}{2} (X^{\top} Y + Y^{\top} X) \end{aligned}\]

while exploiting zero or constant columns in the data matrix. WARNING: Directly use moments_XXXY() if you can. The covars function does an additional constant-matrix multiplication and does not return the mean.

Parameters:
  • X (ndarray (T, M)) – Data matrix

  • Y (ndarray (T, N)) – Second data matrix

  • remove_mean (bool) – True: remove column mean from the data, False: don’t remove mean.

  • modify_data (bool) – If remove_mean=True, the mean will be removed in the data matrix X, without creating an independent copy. This option is faster but might lead to surprises because your input array is changed.

  • symmetrize (bool) – Computes symmetrized means and moments (see above)

  • weights (None or ndarray(T, )) – weights assigned to each trajectory point of X. If None, all data points have weight one. If ndarray, each data point is assigned a separate weight.

  • sparse_mode (str) –

    one of:
    • ’dense’ : always use dense mode

    • ’sparse’ : always use sparse mode if possible

    • ’auto’ : automatic

  • sparse_tol (float) – Threshold for considering column to be zero in order to save computing effort when the data is sparse or almost sparse. If max(abs(X[:, i])) < sparse_tol, then row i (and also column i if Y is not given) of the covariance matrix will be set to zero. If Y is given and max(abs(Y[:, i])) < sparse_tol, then column i of the covariance matrix will be set to zero.

Returns:

  • C_XX (ndarray (M, M)) – Covariance matrix of X

  • C_XY (ndarray (M, N)) – Covariance matrix of XY

See also

moments_XXXY