Bhattacharyya Distance Calculator
Statistics
- Inputs: distribution 1 has mean 50.00 and SD 5.00; distribution 2 has mean 52.00 and SD 6.00.
- Combined variance: 5.00^2 + 6.00^2 = 61.00.
- Coefficient: sqrt(60.00 / 61.00) x exp(-4.00 / 244.00) = 0.9756.
- Bhattacharyya distance result: -ln(0.9756) = 0.0247.
How much do two distributions overlap? The question sounds soft, but it has a hard answer with a distinguished pedigree: the measure Anil Bhattacharyya proposed in 1943, built from the geometric overlap of the two density curves. For normal distributions it collapses into a closed form with two interpretable parts - a factor that punishes mismatched spreads and an exponential that punishes separated means - and its logarithm is the Bhattacharyya distance, a number that bounds the error of the best possible classifier between the two populations.
This calculator takes the two means and two standard deviations and returns the distance with the coefficient behind it and the two components separated, so you can see whether a large distance is being driven by the means, the spreads or both. The examples show near-identical distributions, two distributions three SDs apart with equal spreads, and a mixed case.
Worked examples
Near-identical distributions
(50 · 5 · 52 · 6)
| Bhattacharyya distance | 0.0247 |
| Bhattacharyya coefficient (BC) | 0.9756 |
| Variance-overlap factor | 0.9918 |
| Mean-separation exponent | 0.9837 |
Equal spreads, means three SDs apart
(100 · 10 · 130 · 10)
| Bhattacharyya distance | 1.1250 |
| Bhattacharyya coefficient (BC) | 0.3247 |
| Variance-overlap factor | 1.0000 |
| Mean-separation exponent | 0.3247 |
Mixed location and scale difference
(0 · 1 · 3 · 2)
| Bhattacharyya distance | 0.5616 |
| Bhattacharyya coefficient (BC) | 0.5703 |
| Variance-overlap factor | 0.8944 |
| Mean-separation exponent | 0.6376 |
Overlap, measured two ways
The Bhattacharyya coefficient is the overlap itself: the integral of the square root of the product of the two densities, a number between 0 and 1 that equals 1 only for identical distributions. The distance is its negative logarithm, which converts the multiplicative overlap into an additive scale where identical distributions sit at 0 and the distance grows without bound as the overlap dies. Both numbers describe the same fact; the coefficient reads like a similarity, the distance like a separation.
For two normal distributions the integral has the closed form this page computes. The coefficient is a variance-overlap factor - the square root of twice the product of the SDs over the sum of the variances - multiplied by a mean-separation exponential. In the first worked example, means of 50 and 52 with SDs of 5 and 6, the combined variance is 61.00, the factor is 0.9918 and the exponential is 0.9837, giving a coefficient of 0.9756 and a distance of just 0.0247.
That decomposition is the page's real output. A distance can be large because the means are far apart, because one distribution is much wider than the other, or both - and the remedy, in any applied problem, differs by cause. Reporting the two factors separately turns a verdict into a diagnosis.
- BC = sqrt(2 sd1 sd2 / (sd1^2 + sd2^2)) x exp(-(mean difference)^2 / (4 (sd1^2 + sd2^2))).
- Bhattacharyya distance = -ln(BC): 0 for identical distributions, unbounded above.
- The variance factor is 1 only when the two SDs are equal.
- The distance bounds the Bayes classification error between the two populations.
The Gaussian closed form
The second worked example isolates the mean term completely. Two distributions with means of 100 and 130 and identical SDs of 10 have a variance factor of exactly 1.0000 - the spreads match perfectly - so the entire coefficient of 0.3247 comes from the separation exponential, and the distance is 1.1250. Three standard deviations of separation, on its own, destroys two thirds of the overlap.
The third example mixes the causes. Means of 0 and 3 with SDs of 1 and 2: the variance factor falls to 0.8944 because the spreads differ twofold, the separation exponential contributes 0.6376, and the coefficient of 0.5703 gives a distance of 0.5616. Neither cause dominates; the decomposition shows a problem that is half location, half scale.
Compare the first and third examples to feel the scale. The first pair, separated by less than half of either SD, sits at 0.0247 - effectively one population wearing two labels. The third, at 0.5616, is more than twenty times further on the distance scale, and a classifier between them starts to be worth building. The distance's logarithmic nature means equal steps multiply the overlap rather than subtracting from it, which is why small distances deserve respect: 0.0247 already encodes a coefficient of 0.9756, not 0.9756's worth of separation from 1 in any linear sense.
| Example | Variance factor | Separation factor | Coefficient | Distance |
|---|---|---|---|---|
| First | 0.9918 | 0.9837 | 0.9756 | 0.0247 |
| Second | 1.0000 | 0.3247 | 0.3247 | 1.1250 |
| Third | 0.8944 | 0.6376 | 0.5703 | 0.5616 |
Worked examples
Example 1: Mean of distribution 1 50; SD of distribution 1 5; Mean of distribution 2 52; SD of distribution 2 6. Bhattacharyya distance = 0.0247. Supporting values: Bhattacharyya coefficient (BC) 0.9756; Variance-overlap factor 0.9918; Mean-separation exponent 0.9837. Inputs: distribution 1 has mean 50.00 and SD 5.00; distribution 2 has mean 52.00 and SD 6.00. Combined variance: 5.00^2 + 6.00^2 = 61.00. Coefficient: sqrt(60.00 / 61.00) x exp(-4.00 / 244.00) = 0.9756. Bhattacharyya distance result: -ln(0.9756) = 0.0247.
Example 2: Mean of distribution 1 100; SD of distribution 1 10; Mean of distribution 2 130; SD of distribution 2 10. Bhattacharyya distance = 1.1250. Supporting values: Bhattacharyya coefficient (BC) 0.3247; Variance-overlap factor 1.0000; Mean-separation exponent 0.3247. Inputs: distribution 1 has mean 100.00 and SD 10.00; distribution 2 has mean 130.00 and SD 10.00. Combined variance: 10.00^2 + 10.00^2 = 200.00. Coefficient: sqrt(200.00 / 200.00) x exp(-900.00 / 800.00) = 0.3247. Bhattacharyya distance result: -ln(0.3247) = 1.1250.
Example 3: Mean of distribution 1 0; SD of distribution 1 1; Mean of distribution 2 3; SD of distribution 2 2. Bhattacharyya distance = 0.5616. Supporting values: Bhattacharyya coefficient (BC) 0.5703; Variance-overlap factor 0.8944; Mean-separation exponent 0.6376. Inputs: distribution 1 has mean 0.00 and SD 1.00; distribution 2 has mean 3.00 and SD 2.00. Combined variance: 1.00^2 + 2.00^2 = 5.00. Coefficient: sqrt(4.00 / 5.00) x exp(-9.00 / 20.00) = 0.5703. Bhattacharyya distance result: -ln(0.5703) = 0.5616.
The Bhattacharyya bound and classification
The distance's claim to permanence is the Bhattacharyya bound: the error probability of the optimal Bayes classifier between two equally likely populations is at most half the coefficient. A coefficient of 0.3247, as in the second example, caps the best possible error rate at about a sixth of cases - before anyone has designed a classifier, the overlap alone has set the ceiling on what classification can achieve. Feature selection in pattern recognition runs on this: candidate features are ranked by the Bhattacharyya distance they induce between the classes.
The bound also explains the measure's survival against simpler rivals. A difference of means ignores spread; a variance ratio ignores location; the Bhattacharyya quantity is the overlap integral itself for the Gaussian case, the actual area the two populations share, and its two factors keep the causes itemised. When the bound is loose - when the coefficient is near 1, like the first example's 0.9756 - no classifier, however clever, can separate the populations, and the honest response is better features, not a better algorithm.
When the Gaussian form does not apply
The closed form is exact for normal distributions and only for them. Real populations with skew, heavy tails or multiple modes can share means and SDs with a Gaussian pair while overlapping quite differently, and feeding their summary statistics into this page returns the Gaussian answer, not theirs. The general coefficient - the integral, or for discrete data the summed square-root products used by the Hellinger distance - is the version that survives non-normality.
A second caution is estimation noise. The distance is computed from sample means and SDs as if they were the populations' own; with small samples the SDs wobble, the variance factor wobbles with them, and the exponential amplifies the wobble in the separation term. Distances from small samples should be read as estimates with error bars the formula does not print, and replicated before they rank anything.
Bhattacharyya against neighbouring measures
Its closest relative on this site is the Hellinger distance, built from the same coefficient: where Bhattacharyya takes the negative logarithm, Hellinger takes the square root of one minus the coefficient, which makes Hellinger a true metric obeying the triangle inequality and bounds it between 0 and 1. The Bhattacharyya distance's unbounded, additive scale suits ranking and bounding; Hellinger's bounded metric suits geometry. Same overlap, two temperaments.
Against the Kolmogorov-Smirnov statistic or a simple standardised mean difference, the Bhattacharyya measure's advantage is that it prices both location and scale in one integral with a probabilistic meaning - the classification bound. Its disadvantage is the Gaussian commitment. Choosing between them is choosing what you believe about the populations, and this page's decomposition at least shows you what the Gaussian belief concludes.
FAQs
What does the Bhattacharyya distance measure?
The overlap of two distributions, expressed as a distance: the negative logarithm of the Bhattacharyya coefficient, the integral of the square root of the product of the densities. Identical distributions give 0; the distance grows without bound as the overlap vanishes.
What distance does the first worked example give?
Means of 50 and 52 with SDs of 5 and 6 overlap heavily: the variance factor is 0.9918, the separation factor 0.9837, the coefficient 0.9756, and the distance just 0.0247 - effectively one population wearing two labels.
Why does the second example have a variance factor of 1.0000?
Because its two SDs are equal, both 10. The variance-overlap factor only punishes mismatched spreads, so the whole coefficient of 0.3247 - and the distance of 1.1250 - comes from the means sitting three SDs apart.
What is the Bhattacharyya bound?
The statement that the best possible Bayes classifier between two equally likely populations errs with probability at most half the coefficient. A coefficient of 0.3247 caps the error near a sixth of cases before any classifier is designed - the overlap alone sets the ceiling.
How does it differ from the Hellinger distance?
They share the same coefficient. Bhattacharyya takes its negative logarithm, giving an unbounded additive scale suited to ranking and error bounds. Hellinger takes the square root of one minus the coefficient, giving a bounded true metric. This site has a page for each.
When should I not use the Gaussian form?
When the populations are visibly non-normal - skewed, heavy-tailed or multimodal. The closed form then returns the Gaussian answer for data that are not Gaussian. Use the general coefficient, summed over categories for discrete data, as the Hellinger page does.