Statistics Probability Basics

Probability measures how likely an event is to happen, expressed as a number between 0 and 1 that you can calculate directly from counting outcomes.

What Probability Measures

Probability is a number between 0 and 1 (or 0% to 100%) that describes how likely an event is. A probability of 0 means the event is impossible; a probability of 1 means it is certain. For simple situations where every outcome is equally likely, probability is calculated as the count of favorable outcomes divided by the total count of possible outcomes -- the full set of possible outcomes is called the sample space.

A Concrete Example: Marbles in a Bag

Suppose a bag contains 10 marbles: 5 red, 3 blue, and 2 green. If you draw one marble at random, the probability of each color equals its count divided by the total of 10.

ColorCountProbability
Red50.5
Blue30.3
Green20.2
Total101.0

Example: Probability From Counts

marbles = {"red": 5, "blue": 3, "green": 2}
total = sum(marbles.values())

for color, count in marbles.items():
    probability = count / total
    print(f"P({color}) = {count}/{total} = {probability}")

p_not_red = 1 - marbles["red"] / total
print(f"P(not red) = {p_not_red}")

# Output:
# P(red) = 5/10 = 0.5
# P(blue) = 3/10 = 0.3
# P(green) = 2/10 = 0.2
# P(not red) = 0.5

The Complement Rule

The complement of an event A is 'A does not happen.' Since something must happen, the probabilities of an event and its complement always add up to 1: P(not A) = 1 - P(A). In the marble example, P(not red) = 1 - 0.5 = 0.5, which correctly matches P(blue) + P(green) = 0.3 + 0.2 = 0.5.

  • Every probability is between 0 and 1, inclusive.
  • The probabilities of all outcomes in a sample space add up to exactly 1.
  • P(not A) = 1 - P(A) for any event A.
  • An impossible event has probability 0; a certain event has probability 1.

Example: Empirical Probability by Simulation

import random

bag = ["red"] * 5 + ["blue"] * 3 + ["green"] * 2
trials = 10000
draws = [random.choice(bag) for _ in range(trials)]

for color in ["red", "blue", "green"]:
    empirical = draws.count(color) / trials
    print(f"Empirical P({color}) ~ {empirical:.3f}")

# Output (varies slightly on each run, but stays close to the theoretical values):
# Empirical P(red)   ~ 0.501
# Empirical P(blue)  ~ 0.298
# Empirical P(green) ~ 0.201
Note: Theoretical probability is calculated from counting outcomes ahead of time (5/10 for red). Empirical (experimental) probability is measured by actually running trials and counting results. With enough trials, the empirical probability converges toward the theoretical one -- a pattern known as the law of large numbers.
Note: Real situations often involve two events at once -- like drawing two marbles, or checking the weather and a coin flip together. The next two lessons cover the addition rule for combining 'or' probabilities and the multiplication rule for combining 'and' probabilities.