Skip to content

Expectation ​

The expected value of random variable XX is defined as

E[X]=∑a∈ΩX(a)P[a]{\mathbb E}[X] = \sum_{a \in \Omega} X(a) {\mathbb P}[a]

It is easy to check that

E[X]=∑u∈Ru⋅P[X=u]=∑u∈range(X)u⋅P[X=u]{\mathbb E}[X] = \sum_{u \in {\mathbb R}​} u \cdot {\mathbb P}[X= u] = \sum_{u \in {\sf range}(X)} u \cdot {\mathbb P}[X=u]

where the notation range(X){\sf range}(X) is defined as {X(a):a∈Ω}\{X(a): a \in \Omega\}. Since we consider a finite sample space, the range of XX is always finite. Denote by min⁡X\min X and max⁡X\max X the minimum and maximum values in range(X){\sf range}(X) respectively.

Example 40

It is easy to check that min⁡X≤E[X]≤max⁡X\min X \leq {\mathbb E}[X] \leq \max X. This is simply because for every u∈range(X)u \in {\sf range}(X), we have u≥min⁡Xu \geq \min X, so

E[X]=∑u∈range(X)u⋅P[X=u]≥(min⁡X)⋅∑u∈range(X)P[X=u]=min⁡X{\mathbb E}[X] =\sum_{u \in {\sf range}(X)} u \cdot {\mathbb P}[X=u] \geq (\min X) \cdot \sum_{u \in {\sf range}(X)} {\mathbb P}[X=u] = \min X

Theorem 41 (Additivity of expectation)

Let XX and YY be random variables. Then

E[X+Y]=E[X]+E[Y]{\mathbb E}[X+Y] = {\mathbb E}[X] + {\mathbb E}[Y]

Exercise 107 (Linearity of expectation)

If c1,…,ckc_1,\ldots, c_k are real numbers and X1,…,XkX_1,\ldots, X_k are random variables, then

E[∑iciXi]=∑iciE[Xi]{\mathbb E}[\sum_i c_i X_i] = \sum_i c_i {\mathbb E}[X_i]

The indicator variable of event E⊆ΩE \subseteq \Omega is a random variable that takes 0/10/1 values, i.e., ζE:Ω→{0,1}\zeta_E: \Omega \rightarrow \{0,1\} such that

ζE(a)={1,if a∈E0,otherwise\zeta_E(a) = \begin{cases} 1, & \text{if}\ a \in E \\ 0, & \text{otherwise} \end{cases}

In other words, this is the (random) predicate indicating whether a∈Ea \in E. It is easy to check that the expected value of an indicator variable ζE\zeta_E is the probability of EE (do you see why?).

E[ζE]=P[E]{\mathbb E}[\zeta_E] = {\mathbb P}[E]

Indicator variables play a central role in probability.

Exercise 108

Prove: Every random variable can be written as a linear combination of indicator variables.

Example 41

Let X=∑iXiX = \sum_i X_i where XiX_i is an indicator random variable ζEi\zeta_{E_i} for event EiE_i. Therefore, E[X]=∑iP[Ei]{\mathbb E}[X] = \sum_i {\mathbb P}[E_i]. This just follows from the linearity of expectation.

Example 42

In a random graph probability space (Γn,P)(\Gamma_n, {\mathbb P}), calculate the expected number of edges.

Proof:

Let XX be the number of edges. So we can write XX as a sum of the pairs X(i,j)X(i,j) where X(i,j)X(i,j) is an indicator of whether there is an edge connecting ii and jj. That is, X=∑{i,j}∈([n]2)X(i,j)X= \sum_{\{i,j\} \in {[n] \choose 2}​} X(i,j). By the linearity of expectation:

E[X]=∑i,jE[X(i,j)]=(n2)/2{\mathbb E}[X] = \sum_{i,j} {\mathbb E}[X(i,j)] = {n \choose 2}/2

Exercise 109

Calculate the following expectations for the probability space ({0,1}n,fp)(\{0,1\}^n, f_p) (see Coin tossing).

  • The number of heads.
  • The number of runs of kk consecutive heads (e.g., 110111110111 has 3 runs of 22 consecutive heads).

Exercise 110

Calculate the expected number of Hamiltonian cycles (contain every vertex) in a random graph.

Toolbox by Hilmy Abiyyu Asad from the Noun Project. © 2026 Me. Built with VitePress.