Skip to content
Tutorials Center
My learning

Topics

Lesson 12 of 57 ยท Probability Foundations

Sample Spaces and Events

Learn the language of probability: experiments, sample spaces, events, set operations, and three ways to assign probabilities (classical, empirical and subjective) with examples.

Probability is the mathematics of uncertain outcomes. Before you can calculate anything you need a precise vocabulary: what can happen, which collections of outcomes you care about, and what it means to assign a number to them. This lesson sets that foundation, and everything later in the course builds on it.

Experiments, outcomes and the sample space

A random experiment is a process whose result cannot be predicted with certainty, though the possible results are known: flipping a coin, rolling a die, drawing a card, measuring a waiting time. Each possible result is an outcome, and the set of all outcomes is the sample space, written S (or ฮฉ).

Experiment Sample space
Flip a coin {H, T}
Roll a die {1, 2, 3, 4, 5, 6}
Flip two coins {HH, HT, TH, TT}
Number of emails in an hour {0, 1, 2, 3, ...} (infinite but countable)
Waiting time for a bus any real number โ‰ฅ 0 (continuous)

Pay attention to what counts as one outcome. For two coins, HT and TH are different outcomes. Getting this wrong is the root of many classic mistakes.

Events

An event is any collection of outcomes, a subset of the sample space. "Roll an even number" is the event {2, 4, 6}. An event occurs if the experiment's outcome is in it.

  • A simple event has one outcome: .
  • The certain event is S itself; the impossible event is the empty set โˆ….

Combining events

Events are sets, so set operations apply. Let A = "even" = {2, 4, 6} and B = "greater than 3" = {4, 5, 6} when rolling a die.

Operation Symbol Meaning Result
Union A โˆช B A or B (or both) {2, 4, 5, 6}
Intersection A โˆฉ B A and B {4, 6}
Complement Aแถœ or A' not A {1, 3, 5}
Difference A โˆ’ B A but not B {2}

Two events are mutually exclusive (disjoint) if they cannot happen together: A โˆฉ B = โˆ…. "Even" and "odd" are mutually exclusive; "even" and "greater than 3" are not.

Python Events as Python sets

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

flowchart LR
    S["Sample space S<br/>all outcomes"] --> E1["Event A<br/>a subset"]
    S --> E2["Event B<br/>a subset"]
    E1 --> U["A union B"]
    E2 --> U
    E1 --> I["A intersect B"]
    E2 --> I

Events are subsets of S; "or" is union, "and" is intersection.

Assigning probabilities

A probability is a number between 0 and 1 attached to an event: 0 means impossible, 1 means certain. There are three common ways to obtain these numbers.

Classical (equally likely outcomes)

If the sample space has n(S) equally likely outcomes and the event A contains n(A) of them:

P(A) = n(A) / n(S)

For a fair die, P(even) = 3/6 = 0.5. It requires that outcomes truly are equally likely (a fair coin, a well-shuffled deck), and it works only for finite sample spaces.

Empirical (relative frequency)

Repeat the experiment many times and see how often the event occurs:

P(A) โ‰ˆ (times A occurred) / (number of trials)

The law of large numbers says this ratio settles near the true probability as trials increase. If a factory finds 37 defects in 1,000 items, it estimates the defect probability at 0.037.

Subjective

Sometimes there is no repeatable experiment: "the probability that this startup succeeds is 20%". This is a degree of belief, and it is the entry point to Bayesian thinking.

Python Classical vs empirical probability

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

With few rolls the estimate wobbles; with many it converges to 0.5.

Listing a sample space by computer

For small experiments, let Python enumerate every outcome and count favorable ones. This is a reliable way to check hand calculations.

Python Two dice: the sum of 7

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A sum of 7 has probability 6/36 = 1/6, the most likely total, because there are more ways to make it than any other. If you had listed the sums 2 to 12 as equally likely outcomes, you would have been wrong. The sum is an event made of several equally likely pairs.

The axioms of probability

Whatever method you use, valid probabilities obey three rules, Kolmogorov's axioms:

  1. P(A) โ‰ฅ 0 for every event A.
  2. P(S) = 1.
  3. If A and B are mutually exclusive, P(A โˆช B) = P(A) + P(B).

Everything else, such as the complement rule and the addition rule, follows from these. The next lesson, probability rules, derives them.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Two fair coins are flipped. How many outcomes are in the sample space?

    HH, HT, TH and TT. HT and TH are different outcomes.
  2. 2. A die is rolled. What is P(number greater than 4)?

    The event is {5, 6}, which has 2 of 6 equally likely outcomes, so the probability is 1/3.
  3. 3. Events A and B are mutually exclusive when...

    Their intersection is empty.
  4. 4. An event has probability 1.3. What does that tell you?

    Probabilities can never exceed 1.

Summary

  • A sample space lists every possible outcome; an event is a subset of it.
  • Union means "or", intersection means "and", complement means "not"; mutually exclusive events have an empty intersection.
  • Classical probability counts equally likely outcomes, empirical probability uses long-run frequency, subjective probability expresses belief.
  • Probabilities lie between 0 and 1, the whole sample space has probability 1, and disjoint events add.
  • Listing outcomes by computer is a good way to check counting by hand.

Next: Probability Rules