Skip to main content

Random Variable

A random variable is a variable whose values depend on outcomes of a random process. It is a mathematical function that assigns a numerical value to each outcome in a sample space of a random experiment.

Definition

A random variable X\mathcal{X} is a function from the sample space Ω\Omega to a measureble space, e.g., the set of real numbers R\mathbb{R}:

X:ΩR \mathcal{X}: \Omega \rightarrow \mathbb{R}

In simpler terms, a random variable maps each possible outcome of a random experiment to a number.

Types of Random Variables

  • Discrete Random Variable: Takes specific, discrete values.
    • Example: The number of heads when flipping a coin 10 times. You can get 0, 1, 2, ..., or 10 heads, but not 3.5 heads.
  • Continuous Random Variable: Takes on an infinite number of possible values.
    • Example: The time it takes to run a race. It could be 12.3 seconds, 12.31 seconds, 12.315 seconds, etc.
Example: Dungeons & Dragons (D&D) 1
What is Dungeons & Dragons (D&D)?

Dungeons & Dragons (D&D) is a fantasy tabletop role-playing game where players assume the roles of characters embarking on adventures in an imaginary world. The outcomes of actions, such as combat or solving puzzles, are determined by dice rolls, making probability and randomness key aspects of the game.

In this series of pages about statistics, we’ll use scenarios from D&D as running examples to make statistical concepts more relatable and engaging. Whether you’re a seasoned player or new to the game, these examples will help connect abstract statistical ideas to fun and practical applications.

Imagine you’re playing D&D, leading a group of adventurers in a fierce battle against a dragon. One of the players, a mighty paladin, attempts to land a critical hit with their weapon. To determine if the attack succeeds, the player rolls a 20-sided die, commonly known as a d20.

The outcome of this roll determines success or failure:

  • A roll of 20 results in a critical hit (an extraordinary success).
  • A roll of 1 results in a critical miss (an extraordinary failure).
  • Any other roll results in a normal outcome, which we’ll explore in future examples.

Let’s define the random variable X\mathcal{X} to represent the outcome of this roll:

  • The sample space Ω\Omega includes all possible outcomes of the d20 roll: Ω={1,2,3,,20}\Omega = \{1, 2, 3, \dots, 20\}
  • The random variable X\mathcal{X} maps each outcome to the number rolled: X(ω)=ω,ωΩ\mathcal{X}(\omega) = \omega, \quad \forall \omega \in \Omega

For example:

  • If the player rolls a 15, then X(ω)=15\mathcal{X}(\omega) = 15.
  • If they roll a 20, then X(ω)=20\mathcal{X}(\omega) = 20, indicating a critical hit.
Try It!

Click the button below to roll the d20 and see how often you get a critical hit!


Footnotes

  1. The idea of using D&D to explain statistical concepts came from Professor Marlos C. Machado's RL class (CMPUT 365) at the University of Alberta.