1.3 Moments and Deviations

Exercise 1.3.1 (Exercise 3.9 [MU17]).

Let {Xi}i∈[1,m] be Bernoulli random variables that are not necessarily mutually independent, and X=∑iXi. Then

𝔼[X2]=∑i∈[1,m]Pr⁡[Xi=1]⁢𝔼[X∣Xi=1].
Proof.

We can derive the proof by

𝔼[X2] =𝔼[∑i∈[1,m]Xi⁢X]=∑i∈[1,m]𝔼[Xi⁢X]
=∑i∈[1,m]Pr⁡[Xi=1]⁢𝔼[X∣Xi=1],

where the first two equalities hold from linearity of expectation, and the last one holds by conditional expectation. ∎

Lemma 1.3.2.

Let {Xi}i∈[1,m] be Bernoulli random variables that are not necessarily mutually independent, and X=∑iXi. Then

Var⁢[X] =∑i∈[1,m]Var⁢[Xi]+∑i,j∈[1,m]i≠jCov⁢[Xi,Xj]
=∑i∈[1,m]Var⁢[Xi]+2⋅∑i,j∈[1,m]i<jCov⁢[Xi,Xj].
Exercise 1.3.3 (Exercise 3.11 [MU17]).

Recall the Bubblesort algorithm. Determine the variance of the number of inversions that need to be corrected by Bubblesort.

Proof.

We introduce {Xi,j} 0-1 random variables, where j∈[1,n] and i∈[1,j−1]. Xi,j is 1 if and only if the ith and the jth element are inverted during the sorting. The variance of X=∑i,jXi,j can be expressed by lemma 1.3.2

Var⁢[X]=∑j∈[1,n]i∈[1,j−1]Var⁢[Xi,j]+2⋅∑j0,j1∈[1,n]i0∈[1,j0−1],i1∈[1,j1−1](i0,j0)<(i1,j1)Cov⁢[Xi0,j0,Xi1,j1].

Xi,j=1 if and only if the ith element is greater than jth element, and thus Pr⁡[Xi,j=1]=1/2. Since 𝔼[Xi,j]=1/2, therefore Var⁢[Xi,j]=1/4.

For Cov⁢[Xi0,j0,Xi1,j1], if the two pairs are disjoint, that {i0,j0}∩{i1,j1}=∅, then Xi0,j0 and Xi1,j1 are independent, therefore Cov⁢[Xi0,j0,Xi1,j1]=0.

On the other hand, if i0,i1,j0,j1 have index overlap, there are (n3) choices, each breaking into 3 categories:

  • •

    if i0=i1, then Xi0,j0⋅Xi1,j1=1 if and only if i0th element is the largest among 3, and thus 𝔼[Xi0,j0⋅Xi1,j1]=1/3.

  • •

    if j0=i1, then Xi0,j0⋅Xi1,j1=1 if and only if j0th element is in the middle, and i0th element is the largest, which halves the probability, and therefore 𝔼[Xi0,j0⋅Xi1,j1]=1/6.

  • •

    if j0=j1, then Xi0,j0⋅Xi1,j1=1 if and only if j0th element is the smallest among 3, and thus 𝔼[Xi0,j0⋅Xi1,j1]=1/3.

We conclude that

Var⁢[X]=∑j∈[1,n]∑i∈[1,j−1]14+2⋅(n3)⋅(13+13+16−34)=n⁢(n−1)8+2⋅112⋅(n3)=172⁢n⁢(n−1)⁢(2⁢n+5).

∎

Exercise 1.3.4 (Exercise 3.13 [MU17]).

Find an example of random variable with finite jth moment for j∈[1,k], but an unbounded k+1th moment.

Proof.

Let X∈ℕ+ have Pr⁡[X=x]=c⋅x−k−2 with c=(∑x∈ℕ+x−k−2)−1. 𝔼[Xk] converges, 𝔼[Xk+1] doesn’t. ∎

Remark 1.3.5.

Ever heard of Pareto tails?

Theorem 1.3.6.

For any random variable X and finite expectation 𝔼[X], finite 𝔼[X2], and finite median m,

  • •

    𝔼[X] is the value c that minimizes the expression 𝔼[(X−c)2].

  • •

    m is the value c that minimizes the expression 𝔼[|X−c|].

Proof.

The first one is immediate, as 𝔼[(X−c)2] minimizes at c=𝔼[X] by expanding the expression.

For second case, we assume that there exists c such that 𝔼[|X−c|]<𝔼[|X−m|], or 𝔼[|X−m|−|X−c|]>0. Since c>m or c<m works the same by symmetry, WLOG we let c>m, then

|X−m|−|X−c|={m−cX≤m2⁢X−m−cm≤X≤cc−mX≥c.

For m<X<c, we have 2⁢X−m−c≤c−m, and for X≥c the expression equals c−m, so

𝔼[|X−m|−|X−c|]≤(m−c)⁢Pr⁡[X≤m]+(c−m)⁢Pr⁡[X>m].

Since for a median m, Pr⁡[X≤m]≥1/2 and Pr⁡[X>m]≤1/2, the right-hand side is at most 0, contradicting the prior assumption of existence of c, and proves that m minimizes the expression 𝔼[|X−c|]. ∎

Lemma 1.3.7.

Let X be a random variable, with mean μ, median m, and finite standard deviation σ. Then |μ−m|≤σ.

Proof.
|𝔼[X]−m| ≤𝔼[|X−m|]
≤𝔼[|X−𝔼[X]|]
≤𝔼[(X−𝔼[X])2]=σ,

where the first and the third inequality follow from theorem 1.2.5, and the second one follows from theorem 1.3.6. ∎

Exercise 1.3.8 (Exercise 3.18 [MU17]).

Show that, for a random variable X with standard deviation σ⁢[X] and t∈ℝ+:

  • •

    Pr⁡[X−𝔼[X]≥t⁢σ⁢[X]]≤1/(1+t2);

  • •

    Pr⁡[|X−𝔼[X]|≥t⁢σ⁢[X]]≤2/(1+t2).

Proof.

Cantelli’s inequality (or one-sided Chebyshev’s inequality) can be proved by:

Pr⁡[X−𝔼[X]≥t⁢σ⁢[X]] =Pr⁡[X−𝔼[X]+u≥t⁢σ⁢[X]+u]
≤Pr⁡[(X−𝔼[X]+u)2≥(t⁢σ⁢[X]+u)2]
≤𝔼[(X−𝔼[X]+u)2](t⁢σ⁢[X]+u)2=𝔼[(X−𝔼[X])2]+u2(t⁢σ⁢[X]+u)2
=σ⁢[X]2+u2(t⁢σ⁢[X]+u)2=φ⁢(u).

The last inequality was established by Chebyshev’s inequality.

φ⁢(u) is minimized at u=σ⁢[X]/t, and thus the first inequality is upper bounded by 1/(1+t2).

By symmetry, the second inequality is proven. ∎

Exercise 1.3.9 (Exercise 3.19 [MU17]).

Using 1.3.8, show lemma 1.3.7.

Proof.

By 1.3.8, we have Pr⁡[X≤σ+μ]≥1/2 and Pr⁡[X≥μ−σ]≥1/2.

By definition of median m, Pr⁡[X≥m]≥1/2 and Pr⁡[X≤m]≥1/2.

Since σ>0 is finite, μ is finite, we have μ−σ≤m≤μ+σ, and thus completes the proof for |m−μ|≤σ. ∎

Exercise 1.3.10 (Exercise 3.20 [MU17]).

Let Y be a nonnegative integer-valued random variable with positive expectation. Prove

𝔼[Y]2𝔼[Y2]≤Pr⁡[Y≠0]≤𝔼[Y].
Proof.

By conditional expectation, we have

𝔼[Y2] =𝔼[Y2∣Y=0]⋅Pr⁡[Y=0]+𝔼[Y2∣Y≠0]⋅Pr⁡[Y≠0]
=𝔼[Y2∣Y≠0]⋅Pr⁡[Y≠0]
≥𝔼[Y∣Y≠0]2⋅Pr[Y≠0],

where the last inequality follows from Jensen’s inequality.

Again by conditional expectation, we have 𝔼[Y]=𝔼[Y∣Y≠0]⋅Pr⁡[Y≠0], and thus

𝔼[Y]2𝔼[Y2]≤Pr⁡[Y≠0].

Since Y is an integer-valued random variable,

Pr⁡[Y≠0] =0⋅Pr⁡[Y=0]+∑y≠01⋅Pr⁡[Y=y]
≤∑y∈ℕy⋅Pr⁡[Y=y]=𝔼[Y].

Another way of seeing it is by a direct application of Markov’s inequality, that Pr⁡[Y≥1]≤𝔼[Y]. ∎

1.3.1 Weak Law of Large Numbers (WLLN)

Theorem 1.3.11 (WLLN).

If {Xi}i∈[1,n] are independent, identically distributed random variables with mean μ and standard deviation σ, then for any constant ε>0,

limn→∞Pr⁡[|1n⁢∑iXi−μ|>ε]=0.