Abstract We define the total variation distance between probability distributions. We also introduce a condition equivalent to this definition and provide a proof.
1 Introduction
The total variation distance is an example of a distance between two probability distributions. In the following, to simplify the discussion, we consider only discrete probability distributions. When the probability mass functions of two probability distributions are denoted as p(x),q(x)p(x), q(x) respectively,
dTV(p,q):=12∑x=−∞∞∣p(x)−q(x)∣\beginalign* d_TV(p, q) &:= \frac12\sum_x=-\infty^\inftyp(x)-q(x) \endalign
is called the total variation distance between the probability distributions p(x),q(x)p(x), q(x).
In this note, we confirm that the total variation distance satisfies the axioms of a distance. We also introduce an equivalent definition and provide a proof.
2 Total Variation Distance Satisfies the Distance Axioms
When XX is a set, a function d:X×X→Rd:X\times X\rightarrow\mathbbR is a distance if it satisfies the following three conditions. These three conditions are called the distance axioms. ①
Non-negativity If d(x,y)=0d(x,y)=0, then x=yx=y. The converse is also true. ②
Symmetry d(x,y)=d(y,x)d(x,y)=d(y,x) ③ Triangle inequality
d(x,z)≤d(x,y)+d(y,z)d(x,z)\leq d(x,y) + d(y,z)
Theorem The total variation distance defines a distance on the set of all discrete probability distributions. In other words, it satisfies the distance axioms.
Proof In the following, let p(x),q(x),r(x)p(x), q(x), r(x) be probability mass functions of discrete probability distributions. Non-negativity is understood from the fact that if ax≥0a_x\geq 0 for all xx and
∑x=−∞∞ax=0\beginalign \displaystyle\sum_x=-\infty^\inftya_x&=0 \endalign
then ax=0a_x= 0 holds. Symmetry can be confirmed as follows by noting that ∣p(x)−q(x)∣=∣q(x)−p(x)∣p(x)-q(x)=q(x)-p(x).
dTV(p,q)=12∑x=−∞∞∣p(x)−q(x)∣= 12∑x=−∞∞∣q(x)−p(x)∣=dTV(q,p)\beginalign d_TV(p,q) = \frac12\sum_x=-\infty^\inftyp(x)-q(x) = \frac12\sum_x=-\infty^\inftyq(x)-p(x) = d_TV(q, p) \endalign
The triangle inequality can be confirmed as follows by noting the triangle inequality that holds for absolute values
∣p(x)−r(x)∣≤∣p(x)−q(x)∣+∣q(x)−r(x)∣p(x)-r(x)\leq p(x)-q(x)+q(x)-r(x)
.
dTV(p(x),r(x))=12∑x=−∞∞∣p(x)−r(x)∣≤12∑x=−∞∞(∣p(x)−q(x)∣+∣q(x)−r(x)∣)=12∑x=−∞∞∣p(x)−q(x)∣+12∑x=−∞∞∣q(x)−r(x)∣=dTV(p,q)+dTV(q,r)\beginalign d_TV(p(x), r(x)) &=\frac12\sum_x=-\infty^\inftyp(x)-r(x)\\ &\leq \frac12\sum_x=-\infty^\infty\left(p(x)-q(x)+q(x)-r(x)\right)\\ &= \frac12\sum_x=-\infty^\inftyp(x)-q(x)+ \frac12\sum_x=-\infty^\inftyq(x)-r(x)\\ &= d_TV(p, q) + d_TV(q, r) \endalign
With this, we have proven that the total variation distance satisfies the distance axioms. ■
3 Another Method for Defining Total Variation Distance
For a function h(x)h(x), ∣∣h∣∣∞:=supx∣h(x)∣h_\infty:=\displaystyle\sup_xh(x) is called the uniform norm of the function h(x)h(x). Although supsup means supremum, for convenience, there is no problem if you read it as the maximum value maxmax if it is difficult to understand.
In fact, the total variation distance can also be defined as follows.
Theorem The following equality holds.
dTV(p,q)=12suph:∥h∥∞≤1(EX∼p(x)[h(X)]−EX∼q(x)[h(X)])\beginalign d_TV(p, q) &= \frac12\sup_h:\\left(\mathbbE_X\sim p(x)[h(X)]-\mathbbE_X\sim q(x)[h(X)]\right) \endalign
Here, EX∼p(x)[h(X)]\mathbbE_X\sim p(x)[h(X)] is the expected value of the statistic h(X)h(X) under the probability distribution p(x)p(x). The same applies to EX∼q(x)\mathbbE_X\sim q(x).
This definition of total variation distance is useful in various situations in statistics and machine learning, such as in arguments evaluating the validity of normal approximations, as represented by Stein's method.
4 Proof of the Theorem in Section 3
We will show that the maximum value on the right-hand side is the total variation distance, and that there exists a function h(x)h(x) that achieves this maximum value among functions with a uniform norm of ∥h∥∞≤1\. As preparation for proving the theorem, we prepare a lemma in Section 4.1.
4.1 Preparation for Proving the TheoremLemma Let X+\mathcalX_+ denote the set of all values of xx for which p(x)−q(x)≥0p(x)-q(x)\geq 0 holds, and X−\mathcalX_- denote the set of all values of xx for which p(x)−q(x)<0p(x)-q(x)< 0 holds. In this case,
∑x∈X+(p(x)−q(x))=∑x∈X−(q(x)−p(x))\beginalign \sum_x\in\mathcalX_+(p(x)-q(x)) &= \sum_x\in\mathcalX_-(q(x)-p(x)) \endalign
holds. In particular, dTV(p,q)=∑x∈X+(p(x)−q(x))\displaystyle d_TV(p,q)=\sum_x\in\mathcalX_+(p(x)-q(x)) holds.
Proof Noting that the sum of probabilities is 11, it can be proven as follows.
∑x∈X+(p(x)−q(x))=(1−∑x∈X−p(x))−(1−∑x∈X−q(x))=∑x∈X−(−p(x)+q(x))\beginalign \sum_x\in\mathcalX_+(p(x)-q(x)) &= \left(1-\sum_x\in\mathcalX_-p(x)\right)-\left(1-\sum_x\in\mathcalX_-q(x)\right)\\ &= \sum_x\in\mathcalX_-(-p(x)+q(x)) \endalign
Also, by expressing the total variation distance using X+\mathcalX_+ and X−\mathcalX_-,
dTV(p,q)=12∑x∈X+∣p(x)−q(x)∣+∑x∈X−∣p(x)−q(x)∣=12∑x∈X+(p(x)−q(x))+∑x∈X−(−p(x)+q(x))=∑x∈X+(p(x)−q(x))\beginalign d_TV(p, q) &= \frac12\left\\right\\\ &= \frac12\left\\sum_x\in\mathcalX_+(p(x)-q(x)) + \sum_x\in\mathcalX_-(-p(x)+q(x))\right\\\ &= \sum_x\in\mathcalX_+(p(x)-q(x)) \endalign
follows. ■
4.2 The Right-Hand Side of the Theorem in Section 3 is Bounded by the Total Variation DistanceUsing ∣∑x=−∞∞ax∣≤∑x=−∞∞∣ax∣\sum_x=-\infty^\inftya_x\right and ∣ab∣≤∣a∣∣b∣a, the right-hand side can be bounded from above as follows.
∣EX∼p(x)[h(X)]−EX∼q(x)[h(X)]∣=∣∑x=−∞∞h(x)p(x)−∑x=−∞∞h(x)q(x)∣=∣∑x=−∞∞h(x)(p(x)−q(x))∣≤∑x=−∞∞∣h(x)∣∣p(x)−q(x)∣\beginalign \left\mathbbE_X\sim p(x)[h(X)] - \mathbbE_X\sim q(x)[h(X)]\right &= \left\sum_x=-\infty^\inftyh(x)p(x) - \sum_x=-\infty^\inftyh(x)q(x)\right\\ &= \left\sum_x=-\infty^\inftyh(x)(p(x) - q(x))\right\\ &\leq \sum_x=-\infty^\inftyh(x)p(x)-q(x) \endalign
Furthermore, continuing the algebraic transformation using the sets X+\mathcalX_+ and X−\mathcalX_- introduced in the lemma, we get the following. Here, the definition of the uniform norm was used in the fourth line.
∑x=−∞∞∣h(x)∣∣p(x)−q(x)∣=∑x∈X+∣h(x)∣(p(x)−q(x))+∑x∈X−∣h(x)∣(−p(x)+q(x))=∑x∈X+∣h(x)∣(p(x)−q(x))+∑x∈X−∣h(x)∣(−p(x)+q(x))≤∑x∈X+(p(x)−q(x))+∑x∈X−(−p(x)+q(x))=2∑x∈X+(p(x)−q(x))=2dTV(p,q)\beginalign &\sum_x=-\infty^\inftyh(x)p(x)-q(x)\\ &= \sum_x\in\mathcalX_+h(x)(p(x)-q(x))+\sum_x\in\mathcalX_-h(x)(-p(x)+q(x))\\ &= \sum_x\in\mathcalX_+h(x)(p(x)-q(x))+\sum_x\in\mathcalX_-h(x)(-p(x)+q(x))\\ &\leq \sum_x\in\mathcalX_+(p(x)-q(x))+\sum_x\in\mathcalX_-(-p(x)+q(x))\\ &= 2\sum_x\in\mathcalX_+(p(x)-q(x))\\ &= 2d_TV(p, q) \endalign
From the inequality obtained, it can be seen that the right-hand side of the theorem is bounded from above using the total variation distance.
12suph:∥h∥∞≤1(EX∼p(x)[h(X)]−EX∼q(x)[h(X)])≤dTV(p,q)\beginalign \frac12\sup_h:\\left(\mathbbE_X\sim p(x)[h(X)]-\mathbbE_X\sim q(x)[h(X)]\right) &\leq d_TV(p, q) \endalign
4.3 Existence of a function for which equality holdsWe confirm that for the following function h(x)h(x), the equality holds in the inequality shown in Section 4.2.
h(x)=1x∈X+−1x∈X−\beginalign h(x) &= \begincases1&x\in\mathcalX_+\\-1&x\in\mathcalX_-\endcases \endalign
At this time,
EX∼p(x)[h(X)]−EX∼q(x)[h(X)]=∑x=−∞∞h(x)p(x)−∑x=−∞∞h(x)q(x)=∑x=−∞∞h(x)(p(x)−q(x))=∑x∈X+h(x)(p(x)−q(x))+∑x∈X−h(x)(p(x)−q(x))=∑x∈X+(p(x)−q(x))+∑x∈X−(−p(x)+q(x))=2∑x∈X+(p(x)−q(x)))=2dTV(p,q)\beginalign &\mathbbE_X\sim p(x)[h(X)] - \mathbbE_X\sim q(x)[h(X)]\\ &= \sum_x=-\infty^\inftyh(x)p(x) - \sum_x=-\infty^\inftyh(x)q(x)\\ &= \sum_x=-\infty^\inftyh(x)(p(x)-q(x))\\ &= \sum_x\in\mathcalX_+h(x)(p(x)-q(x))+\sum_x\in\mathcalX_-h(x)(p(x)-q(x))\\ &= \sum_x\in\mathcalX_+(p(x)-q(x))+\sum_x\in\mathcalX_-(-p(x)+q(x))\\ &= 2\sum_x\in\mathcalX_+(p(x)-q(x)))\\ &= 2d_TV(p ,q) \endalign
Since this holds, we can see that the equality in the inequality shown in Section 4.2 holds as follows.
12suph:∥h∥∞≤1(EX∼p(x)[h(X)]−EX∼q(x)[h(X)])=dTV(p,q)\beginalign \frac12\sup_h:\\left(\mathbbE_X\sim p(x)[h(X)]-\mathbbE_X\sim q(x)[h(X)]\right) &= d_TV(p, q) \endalign*
With this, the theorem stated in Section 3 has been proven.
Acknowledgement
I would like to express my gratitude to those who support me daily, and to everyone at Sugakubunka Inc..