Calculators
Total Variation Distance Calculator
Calculate total variation distance between probability distributions with automatic normalization of counts or weights, 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 total variation distance works
Total variation distance is TV(P, Q) = Σ|pᵢ − qᵢ| / 2 for discrete distributions over the same categories. Each vector is independently normalized to sum to one. The result ranges from 0 for matching distributions to 1 for disjoint support. For A = (1, 3) and B = (3, 1), the distance is 0.5. It is the largest absolute probability difference across any set of categories. Counts and non-negative weights are accepted: A = (1, 3) and B = (2, 6) give zero because proportions match. This compares relative distributions, not absolute totals. Keep categories in the same order, including zero entries for missing categories. Each vector accepts 1 to 10000 values separated by spaces, commas or semicolons, up to 200000 characters. Scientific notation is supported; nonzero values must be from 1e-100 to 1e100. All-zero vectors and mismatched lengths are rejected. Scaling before normalization avoids overflowing totals. Results show up to 12 significant digits; very small differences may round away in browser floating-point arithmetic. Everything runs locally in your browser.
Frequently Asked Questions
Everything you need to know about this tool, how it works, and privacy.
What formula is used?
TV(P, Q) = one half of the sum of absolute differences between corresponding normalized probabilities.
Must my inputs sum to one?
No. Each non-negative vector is normalized independently. Counts, weights and probabilities work, provided each vector has at least one positive value.
What do zero and one mean?
Zero means matching proportions. One means disjoint support: no category has positive probability in both distributions.
How does this differ from Manhattan distance?
This calculator normalizes each vector and halves the Manhattan distance between the resulting probabilities. Raw Manhattan distance does not normalize inputs.
What input limits apply?
Enter equal-length vectors of 1 to 10000 non-negative numbers with matching category order, up to 200000 characters each. Nonzero values must be from 1e-100 to 1e100. Results use floating-point arithmetic with up to 12 significant digits.