AI Glossary / Data science and analytics / Advanced
Total Variation Distance (Tvd)
Definition
Total variation distance, usually abbreviated TVD or TV, measures how different two probability distributions are. Under the convention used here, it is the largest absolute difference between the probabilities the distributions assign to the same measurable event. It ranges from zero to one. For discrete distributions, it equals half the sum of absolute differences between corresponding probabilities.
What it means
Suppose two datasets describe the proportions of resources in several formats. TVD summarizes the difference between those distributions, using the same categories for both. It compares probability mass, rather than the raw number of records.
A value of zero means the distributions agree on every event. A value of one represents complete separation in probability mass. Intermediate values bound how much the probabilities of an event can differ, under the distributions being compared.
The number does not tell you why a difference occurred or whether it matters operationally. A change in the mix of resource formats may reflect a deliberate editorial decision, a change in readers or a recording error. Interpretation requires context beyond the distance itself.
How it works
For a shared discrete set of categories, write their probabilities as p1, p2 and so on for one distribution, and q1, q2 and so on for the other. Compute the absolute difference in each category, add those differences and divide by two: TVD = 0.5 × sum of |pi − qi|.
Both probability lists must sum to one and refer to the same outcomes. Include a category with probability zero when it is absent from one distribution but present in the other. Do not align values by position if category labels differ.
The factor of one-half avoids counting both the excess mass and its matching deficit. Some mathematical conventions use a total-variation norm without this factor, so state the convention when comparing reported numbers. For continuous distributions, the corresponding density formula uses an integral instead of a sum.
Three practical examples
- An editorial team compares the proportions of articles, videos and audio resources in two releases. TVD gives one summary of the mix change, while category differences show where it occurred.
- An analyst compares a generator's categorical output distribution with a reference distribution. A small TVD for that field does not establish that relationships with other fields are preserved.
- A monitoring team tracks a categorical input distribution over time. It investigates increases in distance alongside sample size, collection changes and model performance, rather than treating a threshold crossing as proof of failure.
Think of it this way
Imagine two equal-sized allocations of tokens across labeled boxes. TVD is the fraction of the total allocation that must be reassigned between boxes to make the allocations match. The analogy concerns probability mass, not proof that particular people or records moved. It also ignores any physical distance between the boxes.
Worked example
Consider two fictional resource-format distributions over Article, Video and Audio. Distribution P is (0.50, 0.30, 0.20), and Q is (0.40, 0.20, 0.40). Each sums to one.
The absolute differences are 0.10, 0.10 and 0.20. Their sum is 0.40, so TVD = 0.40 / 2 = 0.20. Audio alone has probability 0.20 under P and 0.40 under Q, a difference of 0.20. Equivalently, the event “Article or Video” has probabilities 0.80 and 0.60, also differing by 0.20.
To transform the allocation P into Q, move 0.10 of the total mass from Article and 0.10 from Video into Audio. This reassigns 0.20 in total. The result is a distance of 0.20, not a statement that every category changed by 20% or that 20% of individual resources were edited.
If these probabilities were estimated from samples, the calculated distance would describe the empirical distributions. Inferring a population change would require considering sampling variability and how the samples were collected.
Illustrative case study
In a fictional project, Hazel Learning monitors its resource catalog by primary format. The team observes a larger TVD between successive monthly snapshots and initially suspects a processing problem.
Editors inspect the category differences and find that the latest release intentionally includes more audio. They also discover that one import used “Podcast” while the established schema used “Audio.” The team documents the appropriate mapping and recalculates the comparison using consistent categories.
Hazel keeps the distance as a descriptive signal and reports the underlying proportions with it. The number helps direct attention, but the interpretation comes from the release plan and data checks. This fictional case illustrates using a distance alert to guide investigation.
Common misconceptions and mistakes
TVD is not a percentage change relative to one category's previous value. It is a distance between complete probability distributions under a stated convention.
It does not account for how far numerical outcomes are apart. Moving all mass from one value to a nearby distinct value gives TVD one, just as moving it to a distant value does. A distance that uses the geometry of outcomes may answer a different question.
Matching individual-variable distributions does not guarantee matching their joint distribution. Binning continuous data also changes the comparison: different bin definitions can hide or reveal differences. Finally, TVD alone is not a significance test and supplies no universal acceptable threshold.
Business use
Use TVD when a bounded summary of distributional difference helps a specific monitoring or evaluation task. Define the categories, normalization and comparison period, and retain the individual differences for diagnosis.
Select action thresholds using the expected variability and consequences in the actual workflow. A small global difference can still involve a rare category important to the business. Combine the summary with relevant subgroup checks and outcome measures rather than treating one number as a complete quality assessment.
People also ask
Can datasets have different sizes?
Yes. Compare their normalized distributions, while considering how sample sizes affect uncertainty.
Can TVD exceed one?
Not under the probability-distance convention used here.
Does zero TVD prove identical records?
No. It establishes agreement for the distributions represented, not record-by-record identity.
Check your understanding
Why divide the example's 0.40 by two?
Answer: The sum counts matching excesses and deficits.
Which event achieves the 0.20 difference?
Answer: Audio, or its complement Article-or-Video.
Why retain category labels?
Answer: The comparison must align the same outcomes.
Related terms
- Probability distribution
- Empirical distribution
- Histogram
- statistical distance
- L1 distance
- distribution shift
- Wasserstein distance
- joint distribution
Learn next
Calculate TVD for two small categorical datasets, then merge two categories and recalculate. Examine which information the coarser representation loses and whether it still answers the original question.
More in Data science and analytics
- Technology mining - Technology mining, often called tech mining, combines analysis of scientific and technical text with bibliometric and related methods to investigate...
- Topological data analysis - Topological data analysis, or TDA, uses mathematical ideas about shape and connectivity to study data.
- Total operating characteristic - The total operating characteristic, or TOC, is a curve for evaluating how a ranked score distinguishes a binary reference outcome across thresholds.
- True negative - A true negative is an outcome in which a classifier predicts the negative class and the reference label is also negative.
- True positive - A true positive is an outcome in which a classifier predicts the positive class and the reference label confirms that class.
- Twyman's law - Twyman's law is a practical warning that an unusually interesting result deserves especially careful checking because an error may explain it.
Sources
Djalil Chafaï, Back to Basics: Total Variation Distance, 2010: definition, discrete formula and probability-mass interpretation. https://djalil.chafai.net/blog/2010/10/14/back-to-basics-total-variation-distance/ Yen-Chi Chen, University of Washington STAT 581 lecture notes, Chapter 2: total variation as a bound on differences in event probabilities. https://faculty.washington.edu/yenchic/26A_stat581/Lec2_large.html The resource distributions and Hazel Learning case are original illustrations. This entry uses the distance normalised to the interval from zero to one.
Previous: Total variation Next: Totally Random Trees Embedding