spd_learn.functional.distance#

spd_learn.functional.distance(A, B, metric='riemann', squared=False)[source]#

Distance between matrices according to a metric.

Compute the distance between two matrices A and B according to a metric [1], or between a set of matrices A and another matrix B.

Parameters:
  • A (ndarray, shape (n, n) or shape (n_matrices, n, n)) – First matrix, or set of matrices.

  • B (ndarray, shape (n, n)) – Second matrix.

  • metric (string | callable, default="riemann") – Metric for distance, can be: “chol”, “euclid”, “harmonic”, “kullback”, “kullback_right”, “kullback_sym”, “logchol”, “logdet”, “logeuclid”, “riemann”, “thompson”, “wasserstein”, or a callable function.

  • squared (bool, default=False) –

    Return squared distance.

    Added in version 0.5.

Returns:

d – Distance between A and B.

Return type:

float or ndarray, shape (n_matrices, 1)

Notes

Changed in version 0.12: Add support for NumPy and PyTorch.

References

[1]

Review of Riemannian distances and divergences, applied to SSVEP-based BCI S. Chevallier, E. K. Kalunga, Q. Barthélemy, E. Monacelli. Neuroinformatics, Springer, 2021, 19 (1), pp.93-106