Hellinger Distance Calculator

Statistics

Hellinger distance0.3742
Bhattacharyya coefficient (sum of sqrt(p q))0.8600
Squared Hellinger distance0.1400
Affinity as a percentage86.00%
How this was calculated
  1. Inputs: across 6 categories the square-root products sqrt(p x q) sum to 0.8600.
  2. Squared distance: 1 - 0.8600 = 0.1400.
  3. Hellinger distance: sqrt(0.1400) = 0.3742.
  4. Hellinger distance result: 0.3742 on the 0-to-1 scale, where 1 means the distributions share no category at all.

Ernst Hellinger introduced the integral behind this distance in 1909, and it has a property most divergence measures lack: it is a true metric. It obeys the triangle inequality, it is symmetric, and it lives on a clean scale from 0, for identical distributions, to 1, for distributions that share no category at all. Where other measures report a divergence in units nobody can picture, the Hellinger distance behaves like a distance in the everyday sense - and it is built from the same overlap quantity, the summed square-root products of the two probability vectors, that statisticians call the Bhattacharyya coefficient.

This calculator takes that summed coefficient - computed category by category as the square root of p times q, added over all categories - and returns the Hellinger distance, its square and the affinity as a percentage. The examples show substantial overlap, strong divergence and near-identity.

Worked examples

Substantial overlap across 6 categories

(0.86 · 6)

Hellinger distance0.3742
Bhattacharyya coefficient (sum of sqrt(p q))0.8600
Squared Hellinger distance0.1400
Affinity as a percentage86.00%

Strong divergence across 4 categories

(0.35 · 4)

Hellinger distance0.8062
Bhattacharyya coefficient (sum of sqrt(p q))0.3500
Squared Hellinger distance0.6500
Affinity as a percentage35.00%

Near-identity across 9 categories

(0.995 · 9)

Hellinger distance0.0707
Bhattacharyya coefficient (sum of sqrt(p q))0.9950
Squared Hellinger distance0.0050
Affinity as a percentage99.50%

A true metric for distributions

Most ways of comparing distributions are divergences, not distances: the Kullback-Leibler divergence is asymmetric and unbounded, and even symmetric cousins often break the triangle inequality, so the 'distance' from A to C can exceed the path through B. Hellinger's construction avoids all of that by working with the square roots of the probabilities. In square-root space the two distributions are points on a sphere, and the Hellinger distance is, up to a constant, the straight-line distance between them - which is why the metric properties come free.

The formula from the coefficient is one subtraction and one square root: the squared Hellinger distance is 1 minus the coefficient, and the distance is its root. In the first worked example the square-root products across 6 categories sum to 0.8600, so the squared distance is 0.1400 and the distance is 0.3742. The distributions share most of their mass but are plainly not the same distribution.

The coefficient itself is worth reporting alongside, as this page does under the name affinity: 0.8600, or 86.00 percent. Affinity reads as the overlap; the distance reads as the separation; and because the relationship between them is exact, quoting both loses nothing and lets two audiences - similarity thinkers and distance thinkers - read the same result.

  • Hellinger distance = sqrt(1 - sum of sqrt(p_i x q_i)) over all categories.
  • The summed square-root products are the Bhattacharyya coefficient in discrete form.
  • The scale is 0 (identical) to 1 (no shared category), and it is a true metric.
  • Squared distance = 1 - coefficient, the form most theory is written in.

The square-root product sum

Each category contributes the square root of the product of its two probabilities, and the contributions have a fairness property the raw overlap lacks: a category where both distributions hold a little mass contributes proportionally more than its size suggests, because the geometric mean inside the root rewards agreement at every scale. A category present in one distribution and absent in the other contributes exactly zero - the harshest verdict, delivered smoothly.

The second worked example shows a coefficient built from disagreement: across 4 categories the products sum to only 0.3500, the squared distance is 0.6500 and the distance is 0.8062 - four fifths of the way to the maximum. Distributions like these are not variations on a theme; they are mostly living in different categories. The affinity of 35.00 percent states the same fact from the overlap side.

The third example is the near-identity end: a coefficient of 0.9950 over 9 categories, a squared distance of 0.0050 and a distance of 0.0707. Note how the square root treats small disagreements: a coefficient shortfall of half a percent becomes a distance of 0.0707, seven percent of the scale. Near identity the Hellinger distance magnifies differences that the coefficient compresses - one reason it is preferred for testing whether two samples really come from the same distribution.

ExampleCoefficient (affinity)Squared distanceHellinger distance
First0.8600 (86.00%)0.14000.3742
Second0.3500 (35.00%)0.65000.8062
Third0.9950 (99.50%)0.00500.0707
Near identity the square root magnifies: a coefficient of 0.9950 - half a percent short of perfect overlap - is already a Hellinger distance of 0.0707.

Worked examples

Example 1: Sum of sqrt(p_i x q_i) over all categories 0.86; Number of categories 6. Hellinger distance = 0.3742. Supporting values: Bhattacharyya coefficient (sum of sqrt(p q)) 0.8600; Squared Hellinger distance 0.1400; Affinity as a percentage 86.00%. Inputs: across 6 categories the square-root products sqrt(p x q) sum to 0.8600. Squared distance: 1 - 0.8600 = 0.1400. Hellinger distance: sqrt(0.1400) = 0.3742. Hellinger distance result: 0.3742 on the 0-to-1 scale, where 1 means the distributions share no category at all.

Example 2: Sum of sqrt(p_i x q_i) over all categories 0.35; Number of categories 4. Hellinger distance = 0.8062. Supporting values: Bhattacharyya coefficient (sum of sqrt(p q)) 0.3500; Squared Hellinger distance 0.6500; Affinity as a percentage 35.00%. Inputs: across 4 categories the square-root products sqrt(p x q) sum to 0.3500. Squared distance: 1 - 0.3500 = 0.6500. Hellinger distance: sqrt(0.6500) = 0.8062. Hellinger distance result: 0.8062 on the 0-to-1 scale, where 1 means the distributions share no category at all.

Example 3: Sum of sqrt(p_i x q_i) over all categories 0.995; Number of categories 9. Hellinger distance = 0.0707. Supporting values: Bhattacharyya coefficient (sum of sqrt(p q)) 0.9950; Squared Hellinger distance 0.0050; Affinity as a percentage 99.50%. Inputs: across 9 categories the square-root products sqrt(p x q) sum to 0.9950. Squared distance: 1 - 0.9950 = 0.0050. Hellinger distance: sqrt(0.0050) = 0.0707. Hellinger distance result: 0.0707 on the 0-to-1 scale, where 1 means the distributions share no category at all.

Reading the 0-to-1 scale

The bounded scale is the Hellinger distance's everyday advantage. A distance of 0.3742 needs no calibration table to interpret roughly: a little over a third of the way from identical to disjoint. The second example's 0.8062 is most of the way to disjoint. Practitioners develop intuitions on this scale the way they do on a correlation coefficient's - imperfectly, but portably across problems, which unbounded divergences never allow.

The maximum deserves its precision: 1 is reached only when every category holding mass in one distribution holds none in the other. Anything short of that - a single shared category with small mass in both - pulls the distance below 1, correctly: two distributions that share even a sliver of the world are not maximally different. The scale's top end is as honest as its bottom.

Hellinger against its relatives

Against its cousin the Bhattacharyya distance - the negative logarithm of this same coefficient, worked for normal distributions on its own page - the Hellinger distance trades the error-bound interpretation for metric geometry and a bounded scale. Against total variation distance, it is smoother: total variation counts only the largest discrepancies' sum and can sit at its maximum while distributions still overlap in shape; Hellinger prices every category's agreement. Against Kullback-Leibler, it is symmetric, bounded and defined even when a category is empty in one distribution - the case that sends KL to infinity.

The family resemblance among all of these is the f-divergences, and Hellinger's is the member whose square is the divergence. That technical fact has a practical consequence: squared Hellinger distances compose and bound other quantities in hypothesis testing, which is why the squared value, 0.1400 in the first example, is reported on this page rather than treated as a mere intermediate.

Feeding the calculator honestly

The input is a single sum, so its honesty is entirely in the summing. Both vectors must be genuine probability distributions over the same categories - each summing to 1, with zeros where a category is absent rather than the category quietly dropped. Dropping unshared categories before summing inflates the coefficient and understates the distance; the categories are the shared world the two distributions are being compared across, and shrinking the world flatters the comparison.

Estimated probabilities carry the usual small-sample caution, sharpened by the square root's magnification near identity: with few observations per category, sampling noise alone manufactures distance. The third example's 0.0707 could be two draws from one distribution counted on small samples. Report the category count and the sample sizes beside any Hellinger distance, as this page's inputs make natural, and replicate before concluding the distributions differ.

FAQs

What is the Hellinger distance?

A true metric between two probability distributions: the square root of one minus the summed square-root products of their probabilities. It runs from 0 for identical distributions to 1 for distributions sharing no category, and it obeys the triangle inequality.

What distance does the first worked example give?

Across 6 categories the square-root products sum to 0.8600, so the squared distance is 0.1400 and the Hellinger distance is 0.3742 - substantial overlap, plainly different distributions. The affinity is 86.00 percent.

How divergent is the second example?

Strongly. Its coefficient is only 0.3500, its squared distance 0.6500 and its distance 0.8062 - four fifths of the way to the maximum of 1, which is reserved for distributions with no shared category at all.

Why does a coefficient of 0.9950 give a distance of 0.0707?

Because of the square root. Near identity, 1 minus the coefficient is tiny - 0.0050 - and its root is proportionally much larger. The Hellinger distance magnifies small disagreements, which suits it to testing whether two samples share a distribution.

How does it differ from the Bhattacharyya distance?

Both are built from the same overlap coefficient. Bhattacharyya takes its negative logarithm - an unbounded scale with a classification-error bound. Hellinger takes the square root of one minus it - a bounded true metric. This site computes each on its own page.

What must I be careful about when computing the input sum?

Use the same category set for both distributions, with explicit zeros for absent categories, and make sure each vector sums to 1. Dropping unshared categories inflates the coefficient and understates the distance. With small samples, noise alone manufactures distance, so report sample sizes too.

Sources

Related calculators

Jensen-Shannon Divergence Calculator
Jensen-Shannon divergence between two Bernoulli (binary) distributions: the bounded, symmetric cousin of KL divergence, reported in bits with the Jensen-Shannon distance.
KL Divergence Calculator
Kullback-Leibler divergence between two Bernoulli (binary) distributions in nats and bits, with the reverse divergence and the symmetrised Jeffreys sum - the information loss when Q stands in for P.
Bray-Curtis Dissimilarity Calculator
The Bray-Curtis dissimilarity between two ecological samples: the sum of absolute abundance differences divided by the sum of all abundances, with the similarity complement.