Course contentsShow
← Computer Science
Lesson 108 of 2,8723. Probability for Computer ScienceFree lesson

Sample Spaces and Events

Define sample spaces, outcomes, and events as the foundation for probability theory.

Sample Spaces and Events

What you'll learn: You'll understand how to describe all possible outcomes of a random process and identify meaningful collections of those outcomes.

What is a Sample Space?

A sample space is the set of all possible outcomes of a random experiment or process. It's the foundation of probability theory—before we can calculate chances, we need to know what could happen.

Think of flipping a coin. The sample space is {Heads, Tails}—those are the only two possible results. For rolling a six-sided die, the sample space is {1, 2, 3, 4, 5, 6}.

In computer science, sample spaces appear everywhere: possible server responses, user inputs, network packet arrivals, or algorithm execution paths with random choices.

Outcomes

An outcome is a single element from the sample space—one specific result. When you roll that die and get a 4, that's one outcome from the sample space.

Events

An event is a subset of the sample space—a collection of one or more outcomes we're interested in. Remember that a subset can contain zero elements (the empty set), one element, or many elements from the original set.

For the die example:

  • Event A: "rolling an even number" = {2, 4, 6}
  • Event B: "rolling greater than 4" = {5, 6}
  • Event C: "rolling a 3" = {3}

Events let us group outcomes by meaningful properties. In testing software, your sample space might be all possible test results, and an event could be "all failures" or "all timeouts."

Key Takeaway: The sample space is the complete set of possible outcomes; events are subsets of that space representing outcomes of interest—the building blocks for calculating probabilities.