Welcome to the fourth and final lesson of this course! In the previous lesson, you discovered that when two events overlap, adding their individual probabilities counts the shared outcomes twice, inflating the result. We even measured the exact size of the error. What we did not do was fix it.
That changes now. In this lesson, you will learn the general addition rule, the formula that corrects for double-counting by subtracting the overlap. By the end, you will be able to compute P(A or B) for any pair of events — overlapping or not — with confidence.
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal
Recall that adding P(A)+P(B) when events share outcomes always overshoots the true probability. The overshoot equals exactly P(A and B), because every shared outcome gets counted once inside P(A) and then again inside P(B).
The fix is refreshingly simple: after adding, subtract the overlap once. That removes the extra copy of every shared outcome and leaves each outcome counted exactly once. Think of it like merging two contact lists on your phone — you combine both lists and then remove the duplicates so no one appears twice.
Here is the formula that puts this fix into practice:
P(A or B)=P(A)+P(B)−P(A and B)
Each piece has a clear job:
P(A) captures every outcome in event A.
P(B) captures every outcome in event B.
P(A and B) is the overlap — the outcomes counted in both of the first two terms.
Subtracting P(A and B) removes the second copy of those shared outcomes so the final result reflects each outcome only once. This formula works for any two events, overlapping or not, which is why it earns the name "general."
Let's revisit the playing-card scenario from the last lesson and walk through the formula carefully. We draw one card from a standard 52-card deck. Event A is that the card is red (26 cards), event B is that the card is a face card (12 cards), and the overlap A and B is that the card is a red face card (6 cards).
With all three values identified, we apply the general addition rule one term at a time:
Find P(A): There are 26 red cards out of 52, so P(A)=5226.
Find P(B): There are 12 face cards out of 52, so P(B)=5212.
Find P(A and B): There are 6 red face cards, so P(A and B)=526.
Combine:
P(A or B)=5226+5212−526=5232≈0.615
The probability of drawing a card that is red or a face card (or both) is about 61.5%. Subtracting 526 brought us from the inflated 5238 we identified last lesson down to the correct 5232.
Now let's see the formula at work in a real-world business setting. An online retailer analyzes 400 customer accounts to see which product categories each person shopped from last month:
Category
Customers
Electronics
140
Clothing
100
Both categories
40
We want the probability that a randomly selected customer bought from at least one of these two categories. Let A be "purchased electronics" and B be "purchased clothing."
P(A)=400140=0.35,P(B)=400100=0.25,P(A and B)=40040=0.10
Plugging into the formula:
P(A or B)=0.35+0.25−0.10=0.50
Half of the customer base bought electronics or clothing (or both) last month. Without subtracting the overlap, we would have reported 0.60 — overstating the result by 10 percentage points. In a marketing or inventory decision, that kind of error could lead to seriously misallocated budget.
You might wonder how this new formula relates to the simpler addition rule from Lesson 2. When two events are mutually exclusive, they share no outcomes, which means P(A and B)=0. Substituting that into the general formula gives:
P(A or B)=P(A)+P(B)−0=P(A)+P(B)
That is exactly the rule you already learned! The simpler formula is just a special case of the general one. Going forward, you can always reach for the general addition rule. If the events happen to be mutually exclusive, the overlap term is simply zero and the subtraction disappears on its own.
The general addition rule as presented covers two events, but real-world problems sometimes involve three or more. The idea extends naturally — you still add, then correct for every pairwise overlap — but each new event introduces additional overlaps to track. For three events A, B, and C, the formula becomes:
P(A or B or C)=P(A)+P(B)+P(C)−P(A and B)−P(A and C)−P(B and C)+P(A and B and C)
Notice the pattern: you subtract every two-way overlap (because each was double-counted) and then add back the three-way overlap (because it was removed one too many times by the subtractions). This alternating add-subtract pattern is known as the inclusion–exclusion principle and generalizes to any number of events. In this course we will focus on the two-event version, but knowing that a systematic extension exists is valuable when you encounter more complex scenarios in practice.
As you start applying the general addition rule on your own, keep these pitfalls in mind:
Forgetting to subtract the overlap. This is the most frequent error and always produces an answer that is too high. If your result seems surprisingly large, double-check whether you subtracted P(A and B).
Subtracting when there is no overlap. Sometimes a problem states that the events are mutually exclusive. In that case the overlap is zero — there is nothing to subtract. Inserting a nonzero value by mistake will push the answer too low.
Confusing "and" with "or." In probability, "or" means at least one of the two events occurs, while "and" means both occur simultaneously. Keeping these two words straight is essential for placing each number in the correct spot in the formula.
In this lesson, you turned the overlap insight from Lesson 3 into a working tool. The general addition rule — P(A or B)=P(A)+P(B)−P(A and B) — corrects double-counting by subtracting the shared outcomes exactly once. You also confirmed that the simpler rule for mutually exclusive events is just a special case where the overlap is zero.
Up next, you will put the general addition rule to work in a series of hands-on practice tasks covering workplace surveys, marketing campaigns, gym memberships, and more. Dive in and build real confidence with the formula!