The Rules of Probability: Predicting the Future

In Descriptive Statistics (Path 2), we acted as historians. We took a dataset that already existed, measured its centre, found its spread, and described its shape.

But data scientists rarely get paid to just describe the past. They get paid to predict the future. Will a customer click this ad? Will this server go offline today? Does this new vaccine actually work, or was the recovery just a coincidence?

To answer these questions, we have to move into Inferential Statistics. And the mathematical engine that drives all inference is Probability.

Probability is simply the mathematics of chance. Before we start modeling massive datasets and normal distributions, we have to understand the fundamental rules of how chance operates on a single, isolated event.

The Core Vocabulary

You cannot calculate the probability of something happening unless you know what is possible. To set up a probability problem, you need to define three things:

  1. The Trial: A single action you are taking that has an uncertain outcome (e.g., flipping a coin, running a script, serving a digital ad).
  2. The Sample Space ($S$): The complete list of absolutely every possible outcome that could happen during that trial. If a software system can only be “Online,” “Offline,” or “Under Maintenance,” your sample space is exactly those three states.
  3. The Event ($A$): The specific outcome you actually care about and want to measure (e.g., the server goes offline).

All basic probability boils down to one simple fraction. The probability of an event happening, written as $P(A)$, is simply the number of ways your event can happen divided by the total number of possible outcomes.

$$P(A) = \frac{\text{Ways Event } A \text{ Can Happen}}{\text{Total Possible Outcomes}}$$

The Golden Rule: A probability is always a number between $0$ and $1$. An event with a probability of $0$ is mathematically impossible. An event with a probability of $1$ is absolutely guaranteed. If you ever calculate a probability of $1.5$ or $-0.2$, stop immediately—you broke the math.

The Three Fundamental Rules

Once you know the probability of single events, you can start combining them to predict real-world scenarios. Every prediction relies on these three logical rules.

1. The NOT Rule (The Complement)

Sometimes, it is much easier to calculate the probability of something not happening. In statistics, the opposite of an event is called its Complement, written as $A’$.

Because the probability of all possible outcomes must add up to exactly $1$ (or 100%), the probability of an event not happening is simply $1$ minus the probability that it does happen.

$$P(\text{Not } A) = 1 – P(A)$$

If historical data shows there is a $20\%$ chance a server goes offline today ($0.20$), then the probability it stays online is $1 – 0.20 = 0.80$.

2. The OR Rule (The Addition Rule)

You use the OR rule when you want to know the probability of at least one of multiple events happening.

If two events are Mutually Exclusive—meaning they cannot possibly happen at the same time (like flipping a coin and getting both Heads and Tails)—you simply add their probabilities together.

$$P(A \text{ or } B) = P(A) + P(B)$$

What if they can happen at the same time? If a customer can buy a laptop ($A$), a mouse ($B$), or both at the same time, you have to subtract the overlapping probability so you don’t accidentally count those “both” customers twice.

$$P(A \text{ or } B) = P(A) + P(B) – P(A \text{ and } B)$$

3. The AND Rule (The Multiplication Rule)

You use the AND rule when you want to know the probability of two events happening together in sequence.

If two events are Independent—meaning the outcome of the first event has absolutely no effect on the outcome of the second event (like flipping a coin twice)—you simply multiply their probabilities together.

$$P(A \text{ and } B) = P(A) \times P(B)$$

Let’s look at a digital marketing example. If there is a $10\%$ chance a customer clicks an ad ($0.10$), and a $5\%$ chance they actually buy the product once on the site ($0.05$), the probability of a random person doing both is $0.10 \times 0.05 = 0.005$ (a half-percent chance).

How to Calculate Basic Probability in Software

Because the fundamental rules of probability rely on straightforward logic (addition, subtraction, and multiplication), you do not need complex statistical libraries to calculate them. You just need to structure the variables correctly.

Microsoft Excel

Assume cell A1 holds $P(A)$ as 0.10 and cell B1 holds $P(B)$ as 0.05.

  • The NOT Rule: =1 - A1
  • The AND Rule (Independent Events): =A1 * B1
  • The OR Rule (Mutually Exclusive): =A1 + B1
  • The OR Rule (With Overlap): Assume cell C1 holds the probability of both happening. The formula is =A1 + B1 - C1.
Python

Basic probability in Python is handled using standard arithmetic variables.

p_A = 0.10  # Probability of clicking ad
p_B = 0.05  # Probability of buying product

# NOT Rule
not_A = 1 - p_A

# AND Rule (Independent)
p_A_and_B = p_A * p_B

# OR Rule (Mutually Exclusive)
p_A_or_B_mutually_exclusive = p_A + p_B

# OR Rule (With Overlap - assuming overlap is 0.02)
p_overlap = 0.02
p_A_or_B = p_A + p_B - p_overlap

print(f"Probability of both (AND): {p_A_and_B}")
R

R functions exactly like Python for basic probability arithmetic.

p_A <- 0.10
p_B <- 0.05

# NOT Rule
not_A <- 1 - p_A

# AND Rule (Independent)
p_A_and_B <- p_A * p_B

# OR Rule (With Overlap of 0.02)
p_overlap <- 0.02
p_A_or_B <- p_A + p_B - p_overlap

print(p_A_and_B)

Probability Venn Explorer

Probability Venn Explorer
Sample Space (Area = 1.0) A B
The OR Rule (Addition Rule)
P(A or B) = P(A) + P(B) – P(A and B)
0.60
=
0.40
+
0.30
0.10

Now that you know the rules of how chance operates on individual, isolated events, we can look at what happens when we run thousands of trials at once. In the next lesson, we will explore how massive amounts of probability data organise themselves into the most famous shape in statistics: The Normal Distribution.

🗺️ Part of Path 3: Probability & Distributions

You are reading step 1 of our module on predicting outcomes. Continue your journey below or view the other learning paths.