induwara.lk
induwara.lkAI · Statistics

Hellinger Distance Calculator

Measure how far apart two probability distributions are. Paste two discrete vectors, or enter two Gaussians, and read the Hellinger distance (bounded 0 to 1), the Bhattacharyya coefficient and the Bhattacharyya distance — with full per-term working, all in your browser, no signup.

By Induwara AshinsanaUpdated Jul 16, 2026
Hellinger & Bhattacharyya distance

Two or more non-negative numbers. Comma, space, or newline separated. Auto-normalised to sum to 1.

Same number of categories as P. Order matters — category i of P is compared with category i of Q.

Presets
Hellinger distance H
0.3687
Bounded in [0, 1]
Bhattacharyya coeff. BC
0.8641
Overlap / affinity (1 = identical)
Bhattacharyya dist. D_B
0.1461
Unbounded [0, ∞)
Squared Hellinger H²
0.1359
Affinity 1 − H² = 0.8641
0 — identical distributionsdisjoint / no overlap — 1

Hellinger distance is a true metric bounded in [0, 1]: 0 means the two distributions are the same, 1 means they share no support.

Decimals

BC = Σ√(pᵢqᵢ) = 0.3742 + 0.4899 = 0.8641

H = √(1 − BC) = √(1 − 0.8641) = 0.3687

D_B = −ln(BC) = −ln(0.8641) = 0.1461

Cross-check. H = √(1 − BC) = 0.3687; the independent sum-of-squares form (1/√2)·√(Σ(√pᵢ − √qᵢ)²) = 0.3687. Both forms of the Hellinger distance agree, as they must.

P vs Q by category

P Q
1
0.7000
0.2000
2
0.3000
0.8000

Per-category working

ipᵢqᵢ√(pᵢqᵢ)(√pᵢ − √qᵢ)²
10.70000.20000.37420.1517
20.30000.80000.48990.1202
TotalsBC = 0.86410.2719

Method: BC = Σ√(pᵢqᵢ), H = √(1 − BC), D_B = −ln(BC) (Bhattacharyya 1943; Hellinger 1909; Cha 2007). Gaussian mode uses the closed form for two univariate normals. Sources are cited in full below. No data leaves this page.

How it works

The Hellinger distance and the two Bhattacharyya quantities all measure the overlap between two probability distributions defined over the same set of outcomes. Everything is built from one number, the Bhattacharyya coefficient, introduced by A. Bhattacharyya in 1943:

BC(P, Q) = Σᵢ √(pᵢ · qᵢ)

BC lies in [0, 1]: it is 1 when P and Q are identical and 0 when they are disjoint. From it the two distances follow directly, using the standard discrete definitions catalogued by Cha (2007):

  1. Bhattacharyya distance D_B = −ln(BC), in [0, ∞). It is 0 for identical distributions and +∞ when the overlap is zero. D_B is symmetric but is not a metric — it fails the triangle inequality.
  2. Hellinger distance H = √(1 − BC), in [0, 1]. Unlike KL divergence it is a true metric: symmetric, bounded, and it obeys the triangle inequality, which is why it is a safe drop-in “distance” for clustering and nearest-neighbour work.
  3. The identity H² = 1 − BC means the affinity 1 − H² recovers BC exactly, so the three outputs are three views of the same overlap.

There is an equivalent second form of the Hellinger distance, H = (1/√2)·√( Σᵢ (√pᵢ − √qᵢ)² ). It is algebraically identical because Σ(√pᵢ−√qᵢ)² = Σpᵢ + Σqᵢ − 2Σ√(pᵢqᵢ) = 2(1 − BC). The calculator computes H both ways and shows them reconciling — a built-in correctness check. Before scoring, each vector is normalised to sum to 1 (the SciPy / scikit-learn convention), so you can paste raw counts or histograms directly.

For two univariate Gaussians the tool uses the closed form. With variances σ₁², σ₂² and means μ₁, μ₂: D_B = ¼·ln(¼·(σ₁²/σ₂² + σ₂²/σ₁² + 2)) + ¼·((μ₁−μ₂)²/(σ₁²+σ₂²)), then BC = exp(−D_B) and H = √(1 − BC). This is cross-checked against the closed-form Gaussian coefficient √(2σ₁σ₂/(σ₁²+σ₂²))·exp(−¼·(μ₁−μ₂)²/(σ₁²+σ₂²)), which is algebraically equal to exp(−D_B).

Worked examples

Overlapping distributions (discrete)

P = [0.7, 0.3], Q = [0.2, 0.8]

  1. BC = √(0.7·0.2) + √(0.3·0.8) = √0.14 + √0.24
  2. = 0.374166 + 0.489898 = 0.864064
  3. D_B = −ln(0.864064) = 0.146147
  4. H = √(1 − 0.864064) = √0.135936 = 0.368695
  5. Cross-check (sum of squares): ½·[(√0.7−√0.2)² + (√0.3−√0.8)²]
  6. = ½·(0.151668 + 0.120204) = 0.135936 → √ = 0.368695 ✓

Disjoint distributions (edge case)

P = [1, 0], Q = [0, 1]

  1. BC = √(1·0) + √(0·1) = 0 (no overlap)
  2. H = √(1 − 0) = 1 (the maximum Hellinger distance)
  3. D_B = −ln(0) = +∞ (reported, not a silent NaN)
  4. The tool warns that the distributions share no support

Two Gaussians (closed form)

N(μ=0, σ=1) vs N(μ=1, σ=2)

  1. Term₁ = ¼·ln(¼·(1/4 + 4 + 2)) = ¼·ln(1.5625) = 0.111572
  2. Term₂ = ¼·((0−1)²/(1+4)) = ¼·0.2 = 0.050000
  3. D_B = 0.161572
  4. BC = exp(−0.161572) = 0.850806
  5. H = √(1 − 0.850806) = √0.149194 = 0.386257

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.