Skip to main content
Engineering LibreTexts

18.1: Random Variable Examples

  • Page ID
    48431
    • Eric Lehman, F. Thomson Leighton, & Alberty R. Meyer
    • Google and Massachusetts Institute of Technology via MIT OpenCourseWare
    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Definition \(\PageIndex{1}\)

    A random variable \(R\) on a probability space is a total function whose domain is the sample space.

    The codomain of \(R\) can be anything, but will usually be a subset of the real numbers. Notice that the name “random variable” is a misnomer; random variables are actually functions.

    For example, suppose we toss three independent, unbiased coins. Let \(C\) be the number of heads that appear. Let \(M = 1\) if the three coins come up all heads or all tails, and let \(M = 0\) otherwise. Now every outcome of the three coin flips uniquely determines the values of \(C\) and \(M\). For example, if we flip heads, tails, heads, then \(C = 2\) and \(M = 0\). If we flip tails, tails, tails, then \(C = 0\) and \(M = 1\). In effect, \(C\) counts the number of heads, and \(M\) indicates whether all the coins match.

    Since each outcome uniquely determines \(C\) and \(M\), we can regard them as functions mapping outcomes to numbers. For this experiment, the sample space is:

    \[\nonumber S = \{HHH,HHT,HTH,HTT,THH,THT,TTH,TTT\}.\]

    Now \(C\) is a function that maps each outcome in the sample space to a number as follows:

    \[\begin{aligned} C(HHH) &= 3 \quad C(THH) = 2 \\ C(HHT) &= 2 \quad C(THT) = 1 \\ C(HTH) &= 2 \quad C(TTH) = 1 \\ C(HTT) &= 1 \quad C(TTT) = 0. \end{aligned}\]

    Similarly, \(M\) is a function mapping each outcome another way:

    \[\begin{aligned} M(HHH) &= 1 \quad M(THH) = 0 \\ M(HHT) &= 0 \quad M(THT) = 0 \\ M(HTH) &= 0 \quad M(TTH) = 0 \\ M(HTT) &= 0 \quad M(TTT) = 1. \end{aligned}\]

    So \(C\) and \(M\) are random variables.

    Indicator Random Variables

    An indicator random variable is a random variable that maps every outcome to either 0 or 1. Indicator random variables are also called Bernoulli variables. The random variable \(M\) is an example. If all three coins match, then \(M = 1\); otherwise, \(M = 0\).

    Indicator random variables are closely related to events. In particular, an indicator random variable partitions the sample space into those outcomes mapped to 1 and those outcomes mapped to 0. For example, the indicator \(M\) partitions the sample space into two blocks as follows:

    \[\nonumber \underbrace{HHH \quad TTT}_{M = 1} \quad \underbrace{HHT \quad HTH \quad HTT \quad THH \quad THT \quad TTH}_{M = 0}.\]

    In the same way, an event \(E\) partitions the sample space into those outcomes in \(E\) and those not in \(E\). So \(E\) is naturally associated with an indicator random variable, \(I_E\), where \(I_E(\omega) = 1\) for outcomes \(\omega \in E\) and \(I_E(\omega) = 0\) for outcomes \(\omega \notin E\). Thus, \(M = I_E\) where \(E\) is the event that all three coins match.

    Random Variables and Events

    There is a strong relationship between events and more general random variables as well. A random variable that takes on several values partitions the sample space into several blocks. For example, \(C\) partitions the sample space as follows:

    \[\nonumber \underbrace{TTT}_{C = 0} \quad \underbrace{TTH \quad THT \quad HTT}_{C = 1} \quad \underbrace{THH \quad HTH \quad HHT}_{C = 2} \quad \underbrace{HHH}_{C = 3}.\]

    Each block is a subset of the sample space and is therefore an event. So the assertion that \(C = 2\) defines the event

    \[\nonumber [C = 2] = \{THH, HTH, HHT\},\]

    and this event has probability

    \[\nonumber \text{Pr}[C = 2] = \text{Pr}[THH] + \text{Pr}[HTH] + \text{Pr}[HHT] = \frac{1}{8} + \frac{1}{8} + \frac{1}{8} = 3/8.\]

    Likewise \([M = 1]\) is the event \(\{TTT, HHH\}\) and has probability \(1/4\).

    More generally, any assertion about the values of random variables defines an event. For example, the assertion that \(C \leq 1\) defines

    \[\nonumber [C \leq 1] = \{TTT, TTH, THT, HTT\},\]

    and so \(\text{Pr}[C \leq 1] = 1/2.\)

    Another example is the assertion that \(C \cdot M\) is an odd number. If you think about it for a minute, you’ll realize that this is an obscure way of saying that all three coins came up heads, namely,

    \[\nonumber [C \cdot M \text{ is odd}] = \{HHH\}.\]


    This page titled 18.1: Random Variable Examples is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Eric Lehman, F. Thomson Leighton, & Alberty R. Meyer (MIT OpenCourseWare) .

    • Was this article helpful?