\( \definecolor{colordef}{RGB}{249,49,84} \definecolor{colorprop}{RGB}{18,102,241} \)

Discrete Random Variables

Random Variables

Definitions

Definition Random Variable
A random variable, denoted \(X\), is a function that assigns a numerical value to each outcome \(\omega\) in a random experiment. We write this value as \(X(\omega)\).
The possible values of \(X\) are the real numbers that \(X\) can take.
Example
Let \(X\) be the number of heads when tossing 2 fair coins: (red coin) and (blue coin). Find \(X(\textcolor{colordef}{H},\textcolor{colorprop}{T})\).

The outcome \((\textcolor{colordef}{H},\textcolor{colorprop}{T})\) means the red coin shows heads (H) and the blue coin shows tails (T). Since \(X\) counts heads, there’s 1 head. Thus, \(X(\textcolor{colordef}{H},\textcolor{colorprop}{T}) = 1\).

Definition Discrete Random Variable
A random variable is discrete if its set of possible values is finite or countably infinite. This means we can list all possible values.
Definition Events Involving a Random Variable
For a random variable \(X\):
  • \((X = x)\): The set of outcomes where \(X\) takes the value \(x\).
  • \((X \leq x)\): The set of outcomes where \(X\) is less than or equal to \(x\).
  • \((X \geq x)\): The set of outcomes where \(X\) is greater than or equal to \(x\).
Example
Let \(X\) be the number of heads when tossing 2 coins: and . List the outcomes for \((X = 0)\), \((X = 1)\), \((X = 2)\), \((X \leq 1)\), and \((X \geq 1)\).

  • \((X = 0) = \{(\textcolor{colordef}{T},\textcolor{colorprop}{T})\}\) (no heads).
  • \((X = 1) = \{(\textcolor{colordef}{T},\textcolor{colorprop}{H}), (\textcolor{colordef}{H},\textcolor{colorprop}{T})\}\) (one head).
  • \((X = 2) = \{(\textcolor{colordef}{H},\textcolor{colorprop}{H})\}\) (two heads).
  • \((X \leq 1) = (X = 0) \cup (X = 1) = \{(\textcolor{colordef}{T},\textcolor{colorprop}{T}), (\textcolor{colordef}{T},\textcolor{colorprop}{H}), (\textcolor{colordef}{H},\textcolor{colorprop}{T})\}\) (at most one head).
  • \((X \geq 1) = (X = 1) \cup (X = 2) = \{(\textcolor{colordef}{T},\textcolor{colorprop}{H}), (\textcolor{colordef}{H},\textcolor{colorprop}{T}), (\textcolor{colordef}{H},\textcolor{colorprop}{H})\}\) (at least one head).

Probability Distribution

Definition Probability Distribution
The probability distribution of a random variable \(X\) lists the probability \(P(X = x_i)\) for each possible value \(x_1,x_2,\dots,x_n\). It can be shown as a table or formula.
Proposition Characteristic of a Probability Distribution
For a random variable \(X\) with possible values \(x_1,x_2,\dots,x_n\), we have
  • \(0 \leq P(X=x_i) \leq 1\) for all \(i=1,\dots,n\),
  • \(\displaystyle\sum_{i=1}^n P(X=x_i) =P(X=x_1)+P(X=x_2)+\dots+P(X=x_n)= 1 \).
Example
Let \(X\) be the number of heads when tossing 2 fair coins: and .
  1. List the possible values of \(X\).
  2. Find the probability distribution.
  3. Create the probability table.
  4. Draw the probability distribution graph.

  1. Possible values: \(0\) (no heads), \(1\) (one head), \(2\) (two heads).
  2. Probability distribution:
    • \(P(X = 0) = P(\{(\textcolor{colordef}{T},\textcolor{colorprop}{T})\}) = \frac{1}{4}\),
    • \(P(X = 1) = P(\{(\textcolor{colordef}{T},\textcolor{colorprop}{H}), (\textcolor{colordef}{H},\textcolor{colorprop}{T})\}) = \frac{2}{4} = \frac{1}{2}\),
    • \(P(X = 2) = P(\{(\textcolor{colordef}{H},\textcolor{colorprop}{H})\}) = \frac{1}{4}\).
  3. Probability table:
    \(x\) 0 1 2
    \(P(X = x)\) \(\frac{1}{4}\) \(\frac{1}{2}\) \(\frac{1}{4}\)
  4. Graph:

Existence of a Random variable with a given Probability Distribution

Usually, defining a random variable begins by establishing:
  1. a sample space, that is, the set of all possible outcomes,
  2. a probability associated with this sample space,
  3. a function \(X\) that assigns a number to each outcome in the sample space.
This is quite a lengthy task. However, often, we prefer to directly define a random variable \(X\) with a given probability distribution, relying on the context of the situation being studied. For example, imagine we survey a class of 30 students about their siblings and obtain these results: 10 students have 0 siblings, 12 have 1 sibling, 5 have 2 siblings, and 3 have 3 siblings. We can then define the random variable \(X\) as the number of siblings of a randomly chosen student, with this probability distribution:
\(x\) 0 1 2 3
\(P(X = x)\) \(\frac{10}{30}\) \(\frac{12}{30}\) \(\frac{5}{30}\) \(\frac{3}{30}\)
The theorem below shows that it is always possible to construct a sample space, a probability, and a function \(X\) to obtain a random variable with this probability distribution.
Theorem Existence of a Random Variable with a Given Probability Distribution
Suppose you have possible values \(x_1, x_2, \ldots, x_n\) and probabilities \(p_1, p_2, \ldots, p_n\).
If:
  • \(0 \leq p_i \leq 1\) for each \(i = 1, 2, \ldots, n\),
  • \(\displaystyle\sum_{i=1}^n p_i = p_1 + p_2 + \cdots + p_n = 1\),
then there exists a random variable \(X\) with the probability distribution \(P(X = x_i) = p_i\) for each \(i = 1, 2, \ldots, n\).
Method Defining a Random Variable \(X\) with a Valid Probability Distribution
In practice, we often define a random variable \(X\) directly by specifying its probability distribution. The key is to ensure that this distribution is valid, meaning it satisfies the conditions for a probability distribution: all probabilities must be non-negative and sum to 1.
Example
We survey a class of 30 students about their siblings and obtain these results: 10 students have 0 siblings, 12 have 1 sibling, 5 have 2 siblings, and 3 have 3 siblings. We define a random variable \(X\) as the number of siblings of a randomly chosen student, with this probability distribution:
\(x\) 0 1 2 3
\(P(X = x)\) \(\frac{10}{30}\) \(\frac{12}{30}\) \(\frac{5}{30}\) \(\frac{3}{30}\)
Determine if this probability distribution is valid.

  • \(P(X = x) \geq 0\) for all \(x = 0, 1, 2, 3\) (true: \(\frac{10}{30}\), \(\frac{12}{30}\), \(\frac{5}{30}\), and \(\frac{3}{30}\) are all non-negative),
  • \(P(X = 0) + P(X = 1) + P(X = 2) + P(X = 3) = \frac{10}{30} + \frac{12}{30} + \frac{5}{30} + \frac{3}{30} = \frac{30}{30} = 1\) (true: the sum equals 1).
Since both conditions are satisfied, the probability distribution is valid.

Measures of Center and Spread

Expectation

The expected value of a random variable \(X\) is the "average you’d expect if you repeated the experiment many times". It’s found by taking all possible values, multiplying each by its probability, and adding them up — essentially a weighted average where the probabilities act as the weights.
Definition Expected Value
For a random variable \(X\) with possible values \(x_1, x_2, \ldots, x_n\), the expected value, \(E(X)\), also called the mean, is:$$\begin{aligned}E(X) &= \sum_{i=1}^{n} x_i P(X = x_i)\\ &= x_1 P(X = x_1) + x_2 P(X = x_2) + \cdots + x_n P(X = x_n)\\ \end{aligned}$$
Example
You toss 2 fair coins, and \(X\) is the number of heads. The probability distribution is:
\(x\) 0 1 2
\(P(X = x)\) \(\frac{1}{4}\) \(\frac{1}{2}\) \(\frac{1}{4}\)
Find the expected value of \(X\).

Calculate \(E(X)\) using the formula:$$\begin{aligned}E(X) &= 0 \times \frac{1}{4} + 1 \times \frac{1}{2} + 2 \times \frac{1}{4} \\ &= \frac{1}{2} + \frac{2}{4} \\ &= 1\end{aligned}$$So, on average, you expect 1 head when tossing 2 coins.

Proposition Linearity of Expectation
For any random variable \(X\) and constants \(a\) and \(b\), the expected value of a linear transformation of \(X\) is:$$ E(aX + b) = aE(X) + b $$This property is derived from two simpler rules:
  • \(E(aX) = aE(X)\) (The expectation of a scaled variable is the scaled expectation).
  • \(E(X+b) = E(X) + b\) (The expectation of a shifted variable is the shifted expectation).

The following derivation relies on the formula for the expectation of a function of a discrete random variable, \(g(X)\), which is given by \(E(g(X)) = \sum g(x_i)P(X=x_i)\).
Let the function be \(g(X) = aX + b\).$$\begin{aligned}E(aX+b) &= \sum_{i} (ax_i + b) P(X=x_i) && \text{(by the formula for } E(g(X))\text{)} \\ &= \sum_{i} (ax_i P(X=x_i) + b P(X=x_i)) && \text{(distribute the probability)} \\ &= \sum_{i} ax_i P(X=x_i) + \sum_{i} b P(X=x_i) && \text{(split the summation)} \\ &= a \sum_{i} x_i P(X=x_i) + b \sum_{i} P(X=x_i) && \text{(factor out constants } a \text{ and } b\text{)} \\ &= a E(X) + b(1) && \text{(using } E(X) \text{ definition and } \sum P(X=x_i)=1\text{)} \\ &= aE(X) + b\end{aligned}$$

Variance and Standard Deviation

The variance measures how spread out the values of a random variable are from its expected value. The standard deviation is the square root of the variance, giving a sense of typical deviation in the same units as \(X\).
Definition Variance and Standard Deviation
The variance, denoted \(V(X)\), is:$$\begin{aligned}V(X) &= \sum_{i=1}^{n} (x_i - E(X))^2 P(X = x_i)\\ &= \left(x_1-E(X)\right)^2 P(X = x_1) + \left(x_2-E(X)\right)^2 P(X = x_2) + \cdots + \left(x_n-E(X)\right)^2 P(X = x_n)\\ \end{aligned}$$The standard deviation, denoted \(\sigma(X)\), is \(\sigma(X) = \sqrt{V(X)}\).
Example
You toss 2 fair coins, and \(X\) is the number of heads. The probability table is:
\(x\) 0 1 2
\(P(X = x)\) \(\frac{1}{4}\) \(\frac{1}{2}\) \(\frac{1}{4}\)
Given \(E(X) = 1\), find the variance.

Calculate \(V(X)\):$$\begin{aligned}V(X) &= (0 - 1)^2 \times \frac{1}{4} + (1 - 1)^2 \times \frac{1}{2} + (2 - 1)^2 \times \frac{1}{4} \\ &= 1 \times \frac{1}{4} + 0 \times \frac{1}{2} + 1 \times \frac{1}{4} \\ &= \frac{1}{4} + 0 + \frac{1}{4} \\ &= \frac{1}{2} \\ \end{aligned}$$The variance is \(\frac{1}{2}\).

Proposition Computational Formula for Variance
A more convenient formula for computation is:$$V(X) = E(X^2) - [E(X)]^2$$

Let \(\mu = E(X)\).$$\begin{aligned}V(X) &= E[(X - \mu)^2] \\ &= E[X^2 - 2\mu X + \mu^2] \\ &= E(X^2) - E(2\mu X) + E(\mu^2) && \text{(by linearity of expectation)} \\ &= E(X^2) - 2\mu E(X) + \mu^2 && \text{(since } \mu \text{ and } \mu^2 \text{ are constants)} \\ &= E(X^2) - 2\mu(\mu) + \mu^2 \\ &= E(X^2) - 2\mu^2 + \mu^2 \\ &= E(X^2) - \mu^2 \\ &= E(X^2) - [E(X)]^2\end{aligned}$$