StatisticsSciPy 1.18 · pandas 3.0 · statsmodels 0.15 · Python 3.12 or 3.13
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
57 small wins to finish your pathNext lesson →

Addition rule of probability

The addition rule of probability is the formula for P(A or B), the chance that at least one of two events happens: P(A) + P(B) − P(A and B).

Last updated: 07 Oct, 2026 · SciPy 1.18

Probability basics found the chance of one event by counting. Questions with an "or" in them, such as "a queen or a heart", combine two events, and the addition rule handles them. The video calls these questions common in aptitude tests and exams.

Adding mutually exclusive events

Recall that two events are mutually exclusive when they cannot occur on the same trial, so P(A and B) = 0. Then the chance of one or the other is the sum of their chances:

The addition rule for mutually exclusive events

For a coin, heads and tails are mutually exclusive, so P(heads or tails) = 1/2 + 1/2 = 1: the coin is certain to land on one of them.

The addition rule with a die and a deck of cards · from the Complete Statistics for Data Science in 6 Hours video · 2:39:09 to 2:43:17

The video's second example rolls a die and asks for P(1 or 3 or 6). The three faces are mutually exclusive, so the rule extends to all three:

Three mutually exclusive faces of a die

Adding events that overlap

Events that can occur on the same trial are not mutually exclusive. Pick one card at random from a deck of 52: it can be a queen and a heart at the same time, the queen of hearts. The video's question is the probability that the card is a queen or a heart.

  • Queens: there are 4, so P(Q) = 4/52.
  • Hearts: there are 13, so P(♥) = 13/52.
  • Queen and heart: only the queen of hearts, so P(Q and ♥) = 1/52.

Adding 4/52 and 13/52 counts the queen of hearts twice, once as a queen and once as a heart. The general addition rule subtracts the overlap once:

The addition rule for events that are not mutually exclusive
Queen or heart
Left, two separate circles for rolling a 1 and rolling a 2 on one die never overlap, so P(1 or 2) = 1/6 + 1/6. Right, the circles for the 4 queens and the 13 hearts overlap in the queen of hearts, so P(queen or heart) = 4/52 + 13/52 − 1/52 = 16/52.

The general rule covers both cases. For mutually exclusive events the overlap P(A and B) is 0 and the subtraction drops out. So there is one rule to remember, with a special case.

A grid of the 52 cards with one row per suit: the queen column and the heart row are shaded, they cross at the queen of hearts, and together they cover 16 cards, so P(queen or heart) = 16/52.

Checking the addition rule on a full deck

The code builds all 52 cards, counts the cards that are a queen or a heart directly, and compares the count with the rule.

ExampleFrom the video, run on Python 3.12
from fractions import Fraction
from itertools import product

ranks = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
suits = ["spades", "hearts", "diamonds", "clubs"]
deck = list(product(ranks, suits))               # 52 (rank, suit) cards

def P(event):
    return Fraction(sum(1 for card in deck if event(card)), len(deck))

queen = lambda c: c[0] == "Q"
heart = lambda c: c[1] == "hearts"
print("cards:", len(deck))
print("P(Q) =", P(queen), " P(heart) =", P(heart), " P(Q and heart) =", P(lambda c: queen(c) and heart(c)))
print("rule:  ", P(queen) + P(heart) - P(lambda c: queen(c) and heart(c)))
print("count: ", P(lambda c: queen(c) or heart(c)), "=", round(float(P(lambda c: queen(c) or heart(c))), 4))
print("without subtracting:", P(queen) + P(heart))

die = range(1, 7)
print("die P(1 or 3 or 6) =", Fraction(sum(1 for x in die if x in (1, 3, 6)), 6))

What the deck count confirms

  • P(Q) = 1/13 and P(heart) = 1/4: Fraction reduces 4/52 and 13/52; they are the same numbers as on the board.
  • The rule and the direct count agree at 4/13, which is 16/52 and about 0.3077.
  • Leaving out the overlap gives 17/52, one card too many: the queen of hearts counted twice.
  • The die gives 1/2: the faces 1, 3 and 6 never overlap, so their chances add with nothing to subtract.

Mutually exclusive vs not mutually exclusive

Mutually exclusiveNot mutually exclusive
Can both happen on one trial?NoYes
P(A and B)0Greater than 0
P(A or B)P(A) + P(B)P(A) + P(B) − P(A and B)
Example from the video1 or 3 or 6 on one roll: 1/2Queen or heart: 16/52

Where you use the addition rule

  • Counting a target group once: customers who bought product A or product B, without counting those who bought both twice.
  • Combining failure modes: the chance a part fails from heat or from vibration, when both can happen together.
  • Checking a model's probabilities: a classifier's classes are mutually exclusive and together cover every case, so the probabilities it gives them must add up to 1.
Watch out. Adding P(A) and P(B) without checking for overlap. If the answer comes out above 1, or larger than it should be, the events share outcomes and P(A and B) has to be subtracted.
Try it yourself
  • Find P(king or black card): change the events to c[0] == "K" and c[1] in ("spades", "clubs"). Is it 4/52 + 26/52 − 2/52 = 7/13?
  • Find P(face card or heart) with c[0] in ("J", "Q", "K"). How many cards are in the overlap?
  • Try two mutually exclusive events, a queen or a king. Is P(Q and K) 0, so that the rule adds the two?

You understood something today that you didn't yesterday.