total_variation_distance

forest.benchmarking.distance_measures.total_variation_distance(P: numpy.ndarray, Q: numpy.ndarray) → float

Computes the total variation distance between two (classical) probability measures P(x) and Q(x).

When x is a finite alphabet then the definition is

\[tvd(P,Q) = (1/2) \sum_x |P(x) - Q(x)|\]

where tvd(P,Q) is in [0, 1]. There is an alternate definition for non-finite alphabet measures involving a supremum.

Parameters:
  • P – Is a dim by 1 np.ndarray.
  • Q – Is a dim by 1 np.ndarray.
Returns:

total variation distance which is a scalar.