pyriemann.utils.distance.distance_kullback

pyriemann.utils.distance.distance_kullback(A, B)

Kullback-Leibler divergence between SPD matrices.

The left Kullback-Leibler divergence between two SPD matrices A and B is:

\[d(\mathbf{A},\mathbf{B}) = \frac{1}{2} \left( \text{tr}(\mathbf{B}^{-1}\mathbf{A}) - n + \log(\frac{\det(\mathbf{B})}{\det(\mathbf{A})}) \right)\]
Parameters
Andarray, shape (…, n, n)

First SPD matrices, at least 2D ndarray.

Bndarray, shape (…, n, n)

Second SPD matrices, same dimensions as A.

Returns
dndarray, shape (…,) or float

Left Kullback-Leibler divergence between A and B.