Probability Basics › Random Variables

Michael BrenndoerferUpdated December 25, 20252 min read
Machine Learning from ScratchAll chapters
Part 1 of 9Statistics 101
Chapter 3Probability Basics › Random Variables
Reading section 3 of 12 · Random Variables · 2 minSection 3 of 12 · 2 min

Book contents

Section 3 of 12 · 2 min read

Probability Basics › Random VariablesOne section · Sections in this chapter3 / 12 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

A random variable is a quantity whose value is uncertain before it is observed. Unlike ordinary variables in mathematics that take fixed values, random variables represent outcomes of random processes that can vary from one observation to another. Random variables connect abstract probability theory and real-world measurements, allowing us to apply mathematical reasoning to uncertain phenomena.

We distinguish between two types of random variables based on the values they can assume:

  • Discrete random variables take on countable values, often integers, such as the number of customers arriving at a store, the count of defective items in a batch, or the outcome of rolling a die.
  • Continuous random variables can take any value within an interval, such as temperature, time, height, or stock prices. The distinction matters because discrete and continuous random variables require different mathematical tools: probability mass functions for discrete cases and probability density functions for continuous cases.

Consider a simple example: let XX represent the outcome of rolling a fair six-sided die. This discrete random variable can take values in the set {1,2,3,4,5,6}\{1, 2, 3, 4, 5, 6\}, each with equal probability 1/61/6. In contrast, if YY represents the time until the next customer arrives at a store, this continuous random variable could take any positive real value, and we describe its behavior using a continuous probability distribution like the exponential distribution.