Discrete Random Variables

Week 6

Author

Maghfira Ramadhani

Published

Sep 22, 2025

Plan

In today’s class we will:

  1. Define (discrete) random variables
  2. Use probability mass function (p.m.f./p.f.) and cumulative distribution function (c.d.f.) to describe discrete r.v. distribution
  3. Use p.f. to compute population descriptive statistics
  4. Use joint p.f. and joint c.d.f. to describe multiple discrete r.v. distribution

Textbook Reference: JA 8; SDG 3.1

Random Variables

A random variable \(X\) is a function that maps each outcome of the sample space \(S\) to a number.

And specifically, a discrete random variables is a random variable with a finite or countable set of possible value.

We denote the possible outcome as \(x_1^*,\ldots,x_k^*\).

This definition is somehow related to how we can write down the outcome of an experiment:


Example:

  • Coin toss: \(S=\{H,T\}\) with \(X=1\) if \(H\) and \(X=0\) if \(T\)
  • Roll a die: \(S=\{1,2,3,4,5,6\}\), with \(X\) equal to the outcome
  • Pick a ball: \(S=\{Red,Blue\}\), with \(X=1\) if Red amd \(X=0\) if Blue
  • Pick three ball: \(S=\{RRR,RRB,\ldots,BBB\}\), with \(X\) equal the number of time we get a red ball

Probability (mass) function (p.m.f/p.f.)

The p.m.f. of a discrete random variable \(X\) , denoted as \(p_X(\cdot)\) gives the probability of each possible value of \(X\):

\[p_X(x_k^*)=P(X=x_k^*).\]


Using the previous examples:

  • Coin toss: For a fair coin, \(p_X(1)=P(H)=0.5\) and \(p_X(0)=P(T)=0.5\).
  • Roll a die: For a fair die, \(p_X(x_l^*)=\frac{1}{6}\) for each \(x_k^*=\{1,2,3,4,5,6\}\).

Applied exercise 1: Picking a ball

A box contains 6 red balls and 4 blue balls. If you pick 3 balls at random , \(X\) is the total number of red balls you get from these 3 picks. Find the p.f. of \(X\).

Applied exercise 1: Picking a ball (cont.)

Plot the p.f.

Cumulative distribution funciton (c.d.f.)

The c.d.f. of a discrete random variable \(X\) , denoted as \(F_X(\cdot)\) gives the probability that \(X\) is less than or equal to any argument \(x_0\) of \(F_X(\cdot)\):

\[F_X(x_0)=P(X\leq x_0)=\sum_{x_k^*\leq x_0}p_X(x_k^*).\]

Applied exercise 1: Picking a ball (cont.)

Find the associated c.d.f. of \(X\).

Applied exercise 2: Six-sided dice (cont.)

\(X\) is the number shown, find the p.f. of \(X\)

Applied exercise 2: Six-sided dice (cont.)

\(X\) is the number shown, find the c.d.f. of \(X\)

Use p.f. or c.d.f. to compute interval probability

Let say we’re interested in knowing \(P(a< X\leq b)\) where \(a\leq b\), we can use the c.d.f or p.f. to compute this probability:

We can also use p.f. to compute population descriptive statistics

Recall the sample mean formula

\[ \overline{x}=\frac{x_1+x_2+\ldots+x_n}{n}=\frac{1}{n}\sum_{i=1}^n x_i. \]

where \(x_i\) here is the observed sample (e.g. age of individuals). If we observe all possible value \(x_k^*\) (it would be all possible age of individuals) and the associated observed sample proportion \(p_k\), then the above sample mean can be rewritten as

\[ \overline{x}=\sum_{k} x_k^* p_k. \] Note that these mean is a function of the observed sample of individuals. By the law of large numbers, as the sample size increase, these sample proportion \(p_k\) gets closer to the probability \(p_X(x_k^*)\).

Population mean or expected value

The population mean or expected value of a discrete random variable \(X\), denoted \(\mu_X\) or \(E(X)\) is

\[\mu_X=E(X)=\sum_{k} x_k^* p_X(x_k^*).\]

Applied exercise 1: Picking a ball (cont.)

A box contains 6 red balls and 4 blue balls. If you pick 3 balls at random , \(X\) is the total number of red balls you get from these 3 picks. Find the expected value of \(X\).

Applied exercise 2: Six-sided dice (cont.)

\(X\) is the number shown when you roll a fair six-sided dice, find the expected value of \(X\)

Population variance or standard deviation

Similarly, the population variance of a discrete random variable \(X\), denoted \(\sigma_X^2\) or \(Var(X)\) is

\[\sigma_X^2=Var(X)=E[(X-\mu_X)^2]=\sum_{k} (x_k^* -\mu_X)^2\ p_X(x_k^*).\] And, the the population standard deviation of a discrete random variable \(X\), denoted \(\sigma_X\) or \(sd(X)\) is

\[\sigma_X=sd(X)=\sqrt{\sigma_X^2}=\sqrt{\sum_{k} (x_k^* -\mu_X)^2\ p_X(x_k^*)}.\]

Applied exercise 1: Picking a ball (cont.)

A box contains 6 red balls and 4 blue balls. If you pick 3 balls at random , \(X\) is the total number of red balls you get from these 3 picks. Find the population variance and standard deviation of \(X\).

Applied exercise 2: Six-sided dice (cont.)

\(X\) is the number shown when you roll a fair six-sided dice, find the population variance and standard deviation of \(X\)

Multiple Discrete Random Variables

We can extend the concept of p.f. and c.d.f. to the case where there are two or more random variables.

The joint p.f. of two discrete random variables \(X\) and \(Y\), denoted as \(p_{XY}(\cdot,\cdot)\), gives the joint probability

\[p_{XY}(x_k^*,y_l^*)=P(X=x_k^*\cap Y=y_l^*)=P(X=x_k^*, Y=y_l^*).\]

And, the joint c.d.f. of two discrete random variables \(X\) and \(Y\), denoted as \(F_{XY}(\cdot,\cdot)\), gives the probability that both \(X\) and \(Y\) are less than or equal to their corresponding argument:

\[F_{XY}(x_0,y_0)=P(X\leq x_0\cap Y=y _0)=P(X\leq x_0, Y\leq y_0).\]

Applied exercise 3: Phone and computer ownership

Suppose a random individual drawn from a population \(S\) of individuals is surveyed to determine the number of phones and computers they own. The joint p.f. is given by the following probability table:

Y (# of comp uters)
0 1 2
0 0.06 0.03 0.01
X (# of phones) 1 0.22 0.48 0.05
2 0.02 0.04 0.09

Applied exercise 3: Phone and computer ownership (cont.)

Using the given probability table, find \(F_{XY}(2,1)\), \(F_{XY}(0,1)\), \(F_{XY}(1,2)\).

Marginal probability

The marginal p.f. of \(X\) and \(Y\) are respectively

\[p_X(x_k^*)=\sum_l p_{XY}(x_k^*,y_l^*),\quad \text{ and }\quad p_Y(y_l^*)=\sum_k p_{XY}(x_k^*,y_l^*).\]

Applied exercise 3: Phone and computer ownership (cont.)

Y (# of comp uters)
0 1 2
0 0.06 0.03 0.01
X (# of phones) 1 0.22 0.48 0.05
2 0.02 0.04 0.09

Conditional probability function

The conditional p.f. of \(X\) given \(Y\) is

\[p_{X|Y}(x_k^*|y_l^*)=P(X=x_k^*|Y=y_l^*)=\frac{p_{XY}(x_k^*,y_l^*)}{p_Y(y_l^*)},\] and similarly the conditional p.f. of \(Y\) given \(X\) is

\[p_{Y|X}(y_l^*|x_k^*)=P(Y=y_l^*|X=x_k^*)=\frac{p_{XY}(x_k^*,y_l^*)}{p_X(x_k^*)}.\]

Applied exercise 3: Phone and computer ownership (cont.)

Find \(p_{X|Y}(0|1)\), \(p_{X|Y}(1|1)\) and \(p_{X|Y}(2|1)\).

Y (# of comp uters)
0 1 2
0 0.06 0.03 0.01
X (# of phones) 1 0.22 0.48 0.05
2 0.02 0.04 0.09

Conditional cumulative probability function

The conditional c.d.f. of \(X\) given \(Y\) is

\[F_{X|Y}(x_0|y_l^*)=P(X\leq x_0|Y=y_l^*)=\sum_{x_k^*\leq x_0} p_{X|Y}(x_k^*|y_l^*),\] and similarly the conditional c.d.f. of \(Y\) given \(X\) is

\[F_{Y|X}(y_0|x_k^*)=P(Y\leq y_0|X=x_k^*)=\sum_{y_l^*\leq y_0} p_{Y|X}(y_l^*|x_k^*).\]

Applied exercise 3: Phone and computer ownership (cont.)

Find \(F_{X|Y}(1|1)\).

Y (# of comp uters)
0 1 2
0 0.06 0.03 0.01
X (# of phones) 1 0.22 0.48 0.05
2 0.02 0.04 0.09

Population conditional mean and population conditional variance

Similar to the unconditional one, using the conditional probability we have to compute these statistics.

The population conditional mean or conditional expectation of \(X\) given \(Y=y_l^*\) is

\[\mu_{X|Y=y_l^*}=E(X|Y=y_l^*)=\sum_{k} x_k^* p_{X|Y}(x_k^*|y_l^*).\]

The **population conditional variance* of \(X\) given \(Y=y_l^*\) is

\[\sigma_{X|Y=y_l^*}^2=Var(X|Y=y_l^*)=\sum_{k} (x_k^*-\mu_{X|Y=y_l^*})^2 p_{X|Y}(x_k^*|y_l^*),\] and the population conditional standard deviation is the square root of \(\sigma_{X|Y=y_l^*}^2\).

Applied exercise 3: Phone and computer ownership (cont.)

Find \(\mu_{X|Y=1}\) and \(\sigma_{X|Y=1}^2\).

Y (# of comp uters)
0 1 2
0 0.06 0.03 0.01
X (# of phones) 1 0.22 0.48 0.05
2 0.02 0.04 0.09

End of Lecture