pyriemann.utils.distance.distance_kullback

pyriemann.utils.distance.distance_kullback(A, B, squared=False)

Kullback-Leibler divergence between SPD/HPD matrices.

The left Kullback-Leibler divergence between two SPD/HPD matrices \(\mathbf{A}\) and \(\mathbf{B}\) is [1]:

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

First SPD/HPD matrices, at least 2D ndarray.

Bndarray, shape (…, n, n)

Second SPD/HPD matrices, same dimensions as A.

squaredbool, default False

Return squared distance.

New in version 0.5.

Returns:
dfloat or ndarray, shape (…,)

Left Kullback-Leibler divergence between A and B.

See also

distance

References

[1]

On information and sufficiency S. Kullback S, R. Leibler. The Annals of Mathematical Statistics, 1951, 22 (1), pp. 79-86