Calculators

Canberra Distance Calculator

Calculate Canberra distance and mean coordinate contribution between two numeric vectors privately in your browser.

Enter equal-length numeric vectors, separated by spaces, commas or semicolons. Negative numbers and scientific notation are supported. Each vector allows 10000 numbers and 200000 characters. Paired zeros contribute zero. Calculation runs locally in your browser.

Your Canberra distance will appear here.

How Canberra distance works

Canberra distance is the sum of |aᵢ − bᵢ| / (|aᵢ| + |bᵢ|) over corresponding coordinates. A pair of zeros contributes 0 by convention. Each term lies between 0 and 1, so the total lies between 0 and the number of dimensions. For A = (1, 2, 0) and B = (2, 4, 0), the distance is 2/3 and the mean contribution is 2/9. Identical vectors have distance 0. A zero paired with a nonzero value contributes 1, as do values of opposite signs. This distance emphasizes relative differences near zero; it does not measure the angle between vectors. The mean contribution divides by all dimensions, including paired zeros, and is not a similarity percentage. Inputs must have equal nonzero lengths and finite decimal values. Separate coordinates with spaces, commas or semicolons; commas are delimiters, not thousands separators. Values too small for JavaScript numbers are rejected. Coordinate terms are scaled before division to avoid overflow for very large finite values. Results use up to 12 significant digits. 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 Canberra distance formula?

Sum |a − b| / (|a| + |b|) for corresponding coordinates. A pair of zeros contributes zero.

What is the range of Canberra distance?

For n coordinates the distance ranges from 0 to n. Identical vectors have distance zero. Each coordinate contributes at most one.

How are negative values and zeros handled?

Negative values are allowed. Opposite signs contribute one. A zero paired with a nonzero value contributes one, while paired zeros contribute zero.

Is the mean contribution a similarity score?

No. It is the total distance divided by all dimensions, including paired zeros. It ranges from zero to one and depends on the included coordinates.

What inputs can I use?

Enter 1 to 10000 finite decimal values in each vector, separated by whitespace, commas or semicolons. Scientific notation is accepted. Vector lengths must match. Each field allows 200000 characters; values that underflow to zero are rejected. Inputs stay in your browser.