hellinger#

mlquantify.utils.method.hellinger(dist1, dist2)[source]#

Compute the Hellinger distance between two probability distributions.

The Hellinger distance is a measure of similarity between two probability distributions. It is defined as:

H(P, Q) = 2 * sqrt(|1 - Σ√(Pᵢ * Qᵢ)|)

Parameters:
dist1array-like

The first probability distribution ( P ), where each element ( Pᵢ ) represents the probability of the ( i )-th event.

dist2array-like

The second probability distribution ( Q ), where each element ( Qᵢ ) represents the probability of the ( i )-th event.

Returns:
float

The Hellinger distance between the two distributions.

Notes

  • The Hellinger distance ranges from 0 to 2, where 0 indicates that the distributions are identical, and 2 indicates that they are completely different.

  • Both input distributions must be valid probability distributions; their elements should be non-negative and sum to 1.

  • The absolute value is used to handle numerical errors that may cause the expression inside the square root to become slightly negative.