Calculators
Bhattacharyya Distance Calculator
Calculate Bhattacharyya distance and coefficient between probability distributions with automatic normalization, privately in your browser.
Enter matching non-negative counts, weights or probabilities. Each vector is normalized independently to sum to 1. Separate values with spaces, commas or semicolons. Each vector allows 1–10000 values and 200000 characters; nonzero values must be between 1e-100 and 1e100. At least one value per vector must be positive. Coordinates must represent the same categories in the same order. Calculation runs locally in your browser.
How Bhattacharyya distance works
Bhattacharyya coefficient is BC = Σ√(PᵢQᵢ), and distance is −ln(BC), using the natural logarithm. Each input vector is normalized independently to sum to one. Identical or proportional vectors give coefficient 1 and distance 0. Disjoint support gives coefficient 0 and infinite distance. For (1, 0) and (1, 3), the coefficient is 0.5 and distance is ln(2), approximately 0.69314718056. The coefficient ranges from 0 to 1; distance ranges from 0 to infinity. Distance is symmetric but does not generally satisfy the triangle inequality. Coordinates must refer to the same categories in the same order. Enter 1 to 10000 non-negative decimal values per vector, separated by spaces, commas or semicolons, up to 200000 characters. Scientific notation is accepted; nonzero values must be between 1e-100 and 1e100. Each vector needs a positive value. Scaled normalization and compensated summation reduce numerical error. Results use browser floating-point arithmetic and up to 12 significant digits; tiny differences can round to zero. All processing stays in your browser.
Frequently Asked Questions
Everything you need to know about this tool, how it works, and privacy.
What is the formula?
Distance is −ln(Σ√(PᵢQᵢ)). The sum is the Bhattacharyya coefficient; this calculator uses natural logarithms.
Must inputs sum to one?
No. Each non-negative vector is normalized independently. Proportional counts produce zero distance. Each vector must contain a positive value.
Why is my distance infinite?
Distributions with disjoint support have zero overlap, a coefficient of zero and infinite distance. Shared zero coordinates contribute zero.
Is this a metric?
The distance is symmetric and non-negative but does not generally satisfy the triangle inequality. It is not a significance test or p-value.
What input limits apply?
Use matching vectors of 1 to 10000 values and up to 200000 characters each. Nonzero values must be between 1e-100 and 1e100. Results show up to 12 significant digits; very small differences may round away.