Total Variation Distance Calculator

Inputs

Total variation distance0.1000
L1 distance0.2000
Overlap coefficient0.9000
Largest category gap0.1000
How this was calculated
  1. Inputs: P = (0.50, 0.30, 0.20), Q = (0.40, 0.40, 0.20).
  2. Category gaps: |0.50 - 0.40| = 0.1000, |0.30 - 0.40| = 0.1000, |0.20 - 0.20| = 0.0000; the L1 distance sums them: 0.2000.
  3. Total variation distance is half the L1 distance - the largest probability gap the two distributions can assign to any single event: 0.2000 / 2 = 0.1000.
  4. Total variation distance: 0.1000 - the two distributions agree on 0.9000 of their mass (the overlap coefficient).

Total variation distance is the most literal answer to the question 'how different are these two distributions?' It is the largest gap between the probabilities they assign to any event - and, by a classical identity, exactly half the sum of their absolute differences across outcomes. Enter two probability lists and the calculator returns the distance with its companion measures.

The scale runs from 0, identical distributions, to 1, distributions that never put mass on the same outcome. Unlike most divergences it is a true metric and needs no units, which is why it appears everywhere from hypothesis testing to differential privacy.

Worked examples

Two close distributions

(0.5 · 0.3 · 0.2 · 0.4 · 0.4 · 0.2)

Total variation distance0.1000
L1 distance0.2000
Overlap coefficient0.9000
Largest category gap0.1000

Half the mass in dispute

(0.7 · 0.2 · 0.1 · 0.2 · 0.3 · 0.5)

Total variation distance0.5000
L1 distance1.0000
Overlap coefficient0.5000
Largest category gap0.5000

Similar but distinguishable

(0.25 · 0.25 · 0.5 · 0.1 · 0.4 · 0.5)

Total variation distance0.1500
L1 distance0.3000
Overlap coefficient0.8500
Largest category gap0.1500

Half the L1 distance, all of the meaning

The first worked example compares (0.50, 0.30, 0.20) with (0.40, 0.40, 0.20). The absolute gaps are 0.10, 0.10 and 0, summing to an L1 distance of 0.2000; half of that is the total variation distance, 0.1000. The largest single-outcome gap is also 0.1000 - the identity between the two definitions made visible.

The event definition is what gives the measure its force. For any yes-or-no question you can ask of the outcome - any event - the two distributions' answers differ by at most the total variation distance. It is a guarantee over all possible questions, not just the outcomes listed.

The second example's distance of 0.5000 means there exists an event the two distributions disagree on by half the entire probability mass - a genuinely large difference, halfway to complete disjointness.

  • TVD = half the L1 distance = the largest gap over all events.
  • The overlap coefficient is 1 minus the distance: the probability mass the two distributions share.
  • Inputs should each sum to 1; the calculator works with the values as entered.

The coupling interpretation

There is a second, probabilistic reading. Imagine drawing one sample from each distribution, paired as cleverly as possible. The smallest achievable probability that the two draws differ equals the total variation distance. In the first example, an optimal pairing makes the draws agree 0.9000 of the time - exactly the overlap coefficient - and differ 0.1000 of the time.

The third example, at distance 0.1500 with overlap 0.8500, sits in the 'similar but distinguishable' band: samples from the two distributions will usually look alike, yet a long run of samples reveals the difference with certainty.

This coupling view is why the measure dominates distribution-testing theory: the distance is precisely the advantage a perfect observer gains in telling the two distributions apart from a single sample.

ExampleTVDL1 distanceOverlapLargest gap
First0.10000.20000.90000.1000
Second0.50001.00000.50000.5000
Third0.15000.30000.85000.1500

Worked examples

Example 1: P, category 1 0.5; P, category 2 0.3; P, category 3 0.2; Q, category 1 0.4; Q, category 2 0.4; Q, category 3 0.2. Total variation distance = 0.1000. Supporting values: L1 distance 0.2000; Overlap coefficient 0.9000; Largest category gap 0.1000. Inputs: P = (0.50, 0.30, 0.20), Q = (0.40, 0.40, 0.20). Category gaps: |0.50 - 0.40| = 0.1000, |0.30 - 0.40| = 0.1000, |0.20 - 0.20| = 0.0000; the L1 distance sums them: 0.2000. Total variation distance is half the L1 distance - the largest probability gap the two distributions can assign to any single event: 0.2000 / 2 = 0.1000. Total variation distance: 0.1000 - the two distributions agree on 0.9000 of their mass (the overlap coefficient).

Example 2: P, category 1 0.7; P, category 2 0.2; P, category 3 0.1; Q, category 1 0.2; Q, category 2 0.3; Q, category 3 0.5. Total variation distance = 0.5000. Supporting values: L1 distance 1.0000; Overlap coefficient 0.5000; Largest category gap 0.5000. Inputs: P = (0.70, 0.20, 0.10), Q = (0.20, 0.30, 0.50). Category gaps: |0.70 - 0.20| = 0.5000, |0.20 - 0.30| = 0.1000, |0.10 - 0.50| = 0.4000; the L1 distance sums them: 1.0000. Total variation distance is half the L1 distance - the largest probability gap the two distributions can assign to any single event: 1.0000 / 2 = 0.5000. Total variation distance: 0.5000 - the two distributions agree on 0.5000 of their mass (the overlap coefficient).

Example 3: P, category 1 0.25; P, category 2 0.25; P, category 3 0.5; Q, category 1 0.1; Q, category 2 0.4; Q, category 3 0.5. Total variation distance = 0.1500. Supporting values: L1 distance 0.3000; Overlap coefficient 0.8500; Largest category gap 0.1500. Inputs: P = (0.25, 0.25, 0.50), Q = (0.10, 0.40, 0.50). Category gaps: |0.25 - 0.10| = 0.1500, |0.25 - 0.40| = 0.1500, |0.50 - 0.50| = 0.0000; the L1 distance sums them: 0.3000. Total variation distance is half the L1 distance - the largest probability gap the two distributions can assign to any single event: 0.3000 / 2 = 0.1500. Total variation distance: 0.1500 - the two distributions agree on 0.8500 of their mass (the overlap coefficient).

Total variation against other divergences

Kullback-Leibler divergence is unbounded and asymmetric, and it explodes when one distribution assigns zero probability to an outcome the other allows. Total variation stays in its 0-to-1 box in all cases and treats the two distributions symmetrically, at the cost of ignoring how probability is rearranged within the shared mass.

Pinsker's inequality links the two worlds: total variation is at most the square root of half the KL divergence, so a small KL guarantees a small TVD, while the reverse need not hold. Hellinger distance sits between them in behaviour and is also a metric; chi-square divergence is the most sensitive of the family to small denominators.

If one distribution gives an outcome probability 0 and the other gives it anything at all, that outcome alone contributes its full mass to the L1 sum - total variation never hides support mismatches.

Using TVD in testing and privacy

In differential privacy, total variation bounds how much an observer's beliefs can shift: neighbouring datasets induce output distributions at small TVD, so no event's probability can move much. In distribution testing, sample complexity results are stated directly in terms of the distance a tester must detect.

Practically, empirical distributions from samples always sit at some positive distance from the truth by sampling noise alone. A measured TVD should be compared against the distance expected from finite samples of the same size before being read as a real difference between populations.

Entering distributions cleanly

List the outcomes in the same order for both distributions, and make each list sum to 1 - if you are comparing empirical frequencies, divide the counts by their totals first. Outcomes where both distributions are zero contribute nothing and can be dropped without changing the result.

For continuous quantities, the distance depends on how the range is binned: finer bins can only increase the measured distance. Report the binning alongside any empirical TVD, or the number cannot be reproduced.

There is a decision-theoretic reading that makes the measure's importance concrete. Suppose you must guess which of the two distributions a single sample came from, with equal prior odds. The best possible strategy - compare the two probabilities outcome by outcome and always back the larger - succeeds with probability one-half plus half the total variation distance. In the first example that is a modest edge over coin-flipping; in the second, at a distance of 0.5000, the observer is right three times in four. Total variation is, quite literally, how much better than chance the truth can be told from one observation.

For continuous distributions the same definition runs through densities: half the integral of the absolute density difference, or equivalently the largest gap over all events. Binning samples to use this calculator replaces the density question with a histogram question, and the answer then depends on the bins - coarse bins hide differences inside them, fine bins manufacture distance from sampling noise. The discrete case computed here is exact for the distributions as entered; treat any empirical application as an estimate whose binning is part of the result.

Estimation from finite samples deserves a final caution, because the plug-in estimator of total variation is biased upward: sampling noise can only push two empirical distributions apart, never together, so a measured distance between two samples of the same underlying distribution is positive on average even though the true distance is zero. The bias shrinks with sample size and grows with the number of outcomes. Before reporting a small measured distance as a discovery, compare it with the distance that pure sampling noise would produce at your sample sizes - a permutation of the pooled data gives that null benchmark directly.

In short: enter two distributions over the same outcomes, read the distance as the largest disagreement any event can show and as half the absolute-difference sum, and remember that its bounded, symmetric, unit-free scale is what makes it the reference distance between distributions across statistics, privacy research and machine learning alike.

FAQs

What distance does the first example give?

The first example gives a total variation distance of 0.1000. The two distributions are close: no event's probability differs by more than a tenth of the total mass.

What is the L1 distance in the first example?

The L1 distance is 0.2000 in the first example - the sum of the absolute gaps 0.10, 0.10 and 0 across the three outcomes. Total variation is always half of it.

What overlap does the first example give?

The overlap coefficient is 0.9000 in the first example: nine-tenths of the probability mass sits on outcomes in proportions both distributions share.

What distance does the second example give?

The second example gives 0.5000 - the distributions share only half their mass, a large difference halfway to the maximum of 1.

What distance does the third example give?

The third example gives 0.1500, with an overlap of 0.8500. The distributions are similar but a long run of samples would distinguish them reliably.

What overlap does the third example give?

The third example's overlap is 0.8500, the complement of its 0.1500 distance: the shared mass the two distributions agree on.

Sources

Related calculators

Hellinger Distance Calculator
The Hellinger distance between two discrete probability distributions from the summed square-root products - a true metric on the 0-to-1 scale.
Bhattacharyya Distance Calculator
The Bhattacharyya distance between two normal distributions from their means and standard deviations - with the overlap coefficient behind it.
Renyi Entropy Calculator
Rényi entropy of a four-outcome distribution for any alpha - with Shannon entropy and min-entropy shown so the family lines up in order.