Guozhen AIGlobal AI field notes and model intelligence

English translation

Define possible values of random variable X

Published:

Category: Probability for AI

Read time: 4 min

Reads: 0

Lesson #4Views are counted together with the original Chinese articleImages are preserved from the source page

Concept Diagram: Definition of a Random Variable

A random variable transforms uncertain experimental outcomes into computable numbers. It serves as the bridge from events to distributions, expectations, and model evaluation.

Random Variable Definition Checklist

I’ll first clarify what a random variable represents. Without a clear understanding of its meaning, subsequent concepts—such as distributions and expectations—lose interpretability.

In the previous article, we covered foundational probability concepts—including conditional probability and independence—essential for understanding relationships among random events. In this article, we delve into a central topic in probability theory: random variables.

Definition of a Random Variable

In probability theory, a random variable is a function that maps outcomes of a random experiment to numerical values. More precisely, given a sample space Ω\Omega (i.e., the set of all possible experimental outcomes), a random variable XX is a measurable function mapping from Ω\Omega to the real numbers R\mathbb{R}:

Random Variable Definition Decision Card

When learning about random variables, first examine how they assign numeric values to random outcomes; then determine whether those values are discrete or continuous. Distributions, expectations, and variances all originate here.

X:ΩRX: \Omega \longrightarrow \mathbb{R}

Example

Suppose we conduct a fair six-sided die roll. The sample space is:

Ω={1,2,3,4,5,6}\Omega = \{1, 2, 3, 4, 5, 6\}

We define a random variable XX representing the number shown on the die. Its definition is:

  • If the outcome is 1, then X=1X = 1
  • If the outcome is 2, then X=2X = 2
  • If the outcome is 3, then X=3X = 3
  • If the outcome is 4, then X=4X = 4
  • If the outcome is 5, then X=5X = 5
  • If the outcome is 6, then X=6X = 6

In this example, XX maps each possible die outcome to a concrete integer, enabling quantitative analysis.

Classification of Random Variables

Random variables fall broadly into two categories: discrete random variables and continuous random variables. While this article focuses primarily on the definition of random variables, we briefly introduce both types here—and explore them in depth in the next article.

Probability-in-Practice Implementation Card

After reading AI-Ready Probability for Beginners: Part 4 — Random Variables and Distributions — Defining Random Variables, take one minute to reflect:

  • Are key concepts clearly distinguished?

  • Can the practice steps be reproduced?

  • Can you restate conclusions in your own words?

  • Discrete random variable: Takes values that are finite or countably infinite. For example, the die-roll result XX can only be one of {1,2,3,4,5,6}\{1,2,3,4,5,6\}.

  • Continuous random variable: Takes any real value within an interval. For instance, a person’s height YY may assume any real value in a plausible physiological range.

Reflecting on Real-World Applications

Suppose we’re building an AI system to predict user purchase behavior. We might model the number of past purchases by a user as a discrete random variable XX, where X{0,1,2,}X \in \{0, 1, 2, \dots\}.

Another relevant random variable could be YY: total spending per online shopping session. Since spending amounts can vary continuously (e.g., $29.99, $30.005, $157.82…), YY is naturally modeled as a continuous random variable.

Relationship Between Random Variables and Distributions

A random variable is far more than a simple mapping—it is intrinsically linked to a probability distribution. Every random variable has an associated distribution describing the likelihood of its possible values.

Definition of a Probability Distribution

A probability distribution specifies the probability that a random variable takes each of its possible values.

  • For a discrete random variable XX, the distribution is described by a probability mass function (PMF), denoted P(X=x)P(X = x), defined as:
P(X=x)=P({ωΩ:X(ω)=x})P(X=x) = P(\{ \omega \in \Omega : X(\omega) = x \})
  • For a continuous random variable YY, the distribution is described by a probability density function (PDF), denoted fY(y)f_Y(y), satisfying:
P(Y[a,b])=abfY(y)dyP(Y \in [a, b]) = \int_a^b f_Y(y) \, dy

Case Demonstration

Let’s compute and visualize the probability distribution of a discrete random variable using Python. Revisiting our die-roll example, XX takes values {1,2,3,4,5,6}\{1,2,3,4,5,6\} with equal probability.

import numpy as np
import matplotlib.pyplot as plt

# Define possible values of random variable X
values = np.array([1, 2, 3, 4, 5, 6])

# Compute probability for each value
probabilities = np.array([1/6] * 6)  # Uniform probability: 1/6 each

# Visualize the probability distribution
plt.bar(values, probabilities)
plt.xlabel('Die Face')
plt.ylabel('Probability')
plt.title('Probability Distribution of a Fair Die Roll')
plt.xticks(values)
plt.ylim(0, 1)
plt.show()

This code computes the PMF of XX and displays it as a bar chart—each face has identical probability 1/61/6.

AI-Ready Probability for Beginners: Part 4 — Application Recap Card

By now, summarize AI-Ready Probability for Beginners: Part 4 — Random Variables and Distributions — Defining Random Variables into a concise recap table: First outline the core narrative, then test comprehension with a small task.

AI-Ready Probability for Beginners: Part 4 — Application Self-Check Card

After finishing AI-Ready Probability for Beginners: Part 4 — Random Variables and Distributions — Defining Random Variables, try walking through a small concrete example end-to-end. Then assess which steps you can now execute independently.

Summary

In this article, we formally defined the concept of a random variable, clarified its relationship with probability distributions, introduced its two main types (discrete and continuous), and illustrated these ideas with intuitive examples and code. In the next article, we’ll dive deeper into the properties and applications of discrete and continuous random variables.

Stay tuned for more installments in this series—and continue strengthening your foundational probability knowledge for AI!

Continue

Keep reading from here

Browse English site

Reader Messages

Reader messages

Questions, corrections, extra sources, or hands-on results can be left here. No login is required.

Max 800 characters

To reduce spam, each message is checked for length, link count, and posting frequency.

0/800

Messages

0 messages
Loading messages...