maths.free › Combinatorics & Graph Theory › 4. Counting › Non-Disjoint Outcomes
Non-Disjoint Outcomes
Investigation A recent buzz marketing campaign for The Pie Hole surveyed patrons on their pie preferences.
Section Preview
Investigation
A recent buzz marketing campaign for The Pie Hole surveyed patrons on their pie preferences. People were asked whether they enjoyed (A) Apple, (B) Blueberry, or (C) Cherry pie (respondents answered yes or no to each type of pie, and could say yes to more than one type). The following table shows the results of the survey.
| Pies enjoyed: | A | B | C | AB | AC | BC | ABC |
| Number of people: | 20 | 13 | 26 | 9 | 15 | 7 | 5 |
How many of those surveyed enjoy at least one of the types of pie? Also, explain why the answer is not 95.
In we explored the sum principle as a way of combining two (or more) sets of disjoint outcomes. What happens if the outcomes are not disjoint?
Something different needs to be done. For example, when counting the number of playing cards that are either face cards or red cards, we cannot apply the sum principle to claim there are \(12 + 26 = 38\) cards. The problem is exactly that six cards are both face cards and red cards. There are a few different ways we can handle this that we will explore in this section.
Counting with Venn Diagrams
To understand how to deal with combining sets of outcomes that are not disjoint, it will be helpful to use some notation from set theory, which we will briefly review here.
Let \(A\) be the set of outcomes for the first event and \(B\) be the set of outcomes for the second event. When we ask for the number of ways either event can happen, the new set of outcomes consists of all outcomes that are in \(A\), or \(B\), or both. This is nothing more than the union of the set \(A\) and \(B\), written \(A \cup B\).
The sum principle only applies when no outcome belongs to both events. The elements that are common to sets \(A\) and \(B\) are the sets in their intersection, written \(A \cap B\). The intersection of two sets is itself a set. If sets \(A\) and \(B\) are disjoint, then there are no elements in the intersection, so the intersection is the empty set, written \(\emptyset\).
We are counting the number of outcomes, so what we are really interested in is the size (or cardinality) of the sets. We write the size of a set \(X\) as \(\card{X}\).
With this notation in hand, we can restate the sum principle as follows.
Now consider what happens to the sum principle when the sets are NOT disjoint. Suppose we want to find \(\card{A \cup B}\) and know that \(\card{A} = 10\) and \(\card{B} = 8\). If we knew that the sets were disjoint, then \(\card{A \cup B}\) would be 18. But if we don't have that the sets are disjoint, we need more information We must know how many of the 8 elements in \(B\) are also elements of \(A\). Suppose we also know that \(\card{A \cap B} = 6\). Now we can say exactly how many elements are in \(A\), and, of those, how many are in \(B\) and how many are not (6 of the 10 elements are in \(B\), so 4 are in \(A\) but not in \(B\)). We could fill in a Venn diagram as follows:
This says there are 6 elements in \(A \cap B\), 4 elements in \(A\) but not \(B\) (which we can write as \(\card{A \setminus B} = 4\)), and 2 elements in \(B\) but not \(A\) (written \(\card{B \setminus A} = 2\)). Now these three sets are disjoint, so we can use the sum principle to find the number of elements in \(A \cup B\). It is \(6 + 4 + 2 = 12\).
We can do something similar with three sets.
Condensed — the full section is in Levin, Discrete Mathematics: An Open Introduction.
The Principle of Inclusion/Exclusion
It would be nice to write an algebraic formula that captures what we have done in the previous examples. Even better would be for this algebraic formula to be a generalization of the case where the sets are disjoint.
Consider again the example where \(\card{A} = 10\), \(\card{B} = 8\) and \(\card{A \cap B} = 6\). We said that \(\card{A \cup B} = 12\), found by adding \(4 + 6 + 2\).
If \(A\) and \(B\) had been disjoint, then \(\card{A \cup B}\) would have been \(\card{A} + \card{B} = 10 + 8 = 18\). We see that is off by exactly 6, which just so happens to be \(\card{A \cap B}\). So perhaps we guess, \[\card{A \cup B} = \card{A} + \card{B} - \card{A \cap B}\]. This makes sense! When we add the number of elements in \(A\) to the number of elements in \(B\), we have counted the six elements that belong to both sets exactly twice. So if we subtract them out, we have counted them exactly once.
In other words, we have:
Example
How many \(7\)-bit strings of weight \(4\) start with \(11\) or end with \(00\), or both? Use and compare to .
Solution
We have \(\card{A} = \binom{5}{2} = 10\), \(\card{B} = \binom{5}{4} = 5\), and \(\card{A \cap B} = \binom{3}{2} = 3\). Therefore: \[\card{A \cup B} = 10 + 5 - 3 = 12\]. This makes sense since the three bit strings that start with \(11\) and end with \(00\) are counted in the 10 strings starting with \(11\) and again among the 5 strings ending with \(00\), so we have over-counted these exactly one time before we subtract them out.
For three sets, we can also count the elements in the union by carefully removing elements we have counted multiple times. Since there are more ways for the sets to overlap, the formula is more complicated.
Condensed — the full section is in Levin, Discrete Mathematics: An Open Introduction.
Overlaps and the Product Principle
Everything we have considered so far in this section has been about how the sum principle applies when the sets of outcomes are not disjoint. Do we need to be similarly worried about overlaps when applying the product principle?
Not really.
One use of the product principle is to compute probabilities, and in that context, we do make a distinction between events being independent or dependent. We will explore this more in . Essentially, to find the probability of two events occuring, we can multiply their respective probabilities if and only if the two events are independent: if the outcome of one event does not affect the outcome of the other.
While finding probability is closely related to counting outcomes, the product principle itself does not require that sets of outcomes be disjoint or make a distinction between dependent or independent events. What does matter is that the number of outcomes for the second event does not change based on which outcome was the result of the first event.
A distinction we do often make when applying the product principle is whether the outcomes of events can be repeated. Consider the following example.
Example
How many 3-letter words (sequences of three letters) are there when,
- repeats are allowed?
- repeats are not allowed?
Solution
Being careful with the product principle, we are combining three events: \(A\) is the event of selecting the first letter, \(B\) is the event of selecting the second letter, and \(C\) is the event of selecting the third letter. If we want to count the number of words when letters in the word can be repeated, then each event contains 26 outcomes. So the number of 3-letter words is \(26^3 = 17,576\) when repeats are allowed.
When repeats are not allowed, then the number of outcomes for event \(A\) is still 26, but the number of outcomes for \(B\) is only 25, since no matter what the outcome of event \(A\) is, that letter cannot be selected for the second position in the word. Similarly, no matter what the outcomes of event \(A\) and \(B\) are, the number of outcomes for event \(C\) is always 24: any letter not selected in the first two events. Thus the number of 3-letter words containing no repeated letters is \(26\cdot 25\cdot 24 = 15,600\).
It's a little strange that the actual set of outcomes for event \(B\) is different for each possible outcome of event \(A\). This doesn't matter though, as long as the size of the outcome set doesn't change.
We will explore problems such as the previous example in much more depth next in . Before that though, here is a final example of where the product principle does NOT easily work.
Condensed — the full section is in Levin, Discrete Mathematics: An Open Introduction.
Practice (6)
Try each one on paper first. Reveal the answer to check; verified ones can be opened in the solver for every step.
-
How did you combine your two lists above? Explain how you did it. Then think of another method you could have used, and explain how that would be different.
-
Which of the following best describes what the Principle of Inclusion/Exclusion is used for?
-
Why does the Principle of Inclusion/Exclusion add the size of the intersection of three sets, rather than subtract? Explain in your own words.
-
What questions do you have after reading this section? Write at least one question about the section you are curious about.
-
Let \(A\), \(B\), and \(C\) be sets.
- \(\card{(A \cup C)\setminus B}\)\(\card{A} = 50\)\(\card{B} = 45\)\(\card{C} = 40\)\(\card{A\cap B} = 20\)\(\card{A \cap C} = 15\)\(\card{B \cap C} = 23\)\(\card{A \cap B \cap C} = 12\)
- \(A\)\(B\)\(C\)
Kusonyeza yankho
Hint:
For part (a) you could use the formula for PIE, but for part (b) you might be better off drawing a Venn diagram.
-
For how many three-digit numbers (100 to 999) is the sum of the digits even? (For example, \(343\) has an even sum of digits: \(3+4+3 = 10\) which is even.) Find the answer and explain why it is correct in at least two different ways.
Kusonyeza yankho
Hint:
You could consider cases. For example, any number of the form ODD-ODD-EVEN will have an even sum. Alternatively, how many three-digit numbers have the sum of their digits even if the first two digits are 54? What if the first two digits are 19?
Symbols used here
Number of k-element subsets of n things: n!/(k!(n−k)!).
In either; in both; in A but not B.
n × (n−1) × … × 1; the number of orderings of n things. 0! = 1.
Add a_k for k = 1 up to n.
Multiply a_k for k = 1 up to n.
The set with no elements; the number of elements of A.
How to: Non-Disjoint Outcomes
- Use Venn diagrams to count the number of outcomes in the union of non-disjoint sets.
- Apply the principle of inclusion/exclusion for two and three sets.
- Explain why the principle of inclusion/exclusion works.
Questions people ask
Permutation or combination?
Ask whether order matters. A lock code is a permutation (order matters); a hand of cards is a combination (it does not).
What is a graph in this sense?
Dots (vertices) joined by lines (edges) — not a plot. Road maps, social networks and molecules are graphs; questions like "is there a route" and "how few colours" are graph theory.
Sankhani wanu
Parts of this page are adapted from Levin, Discrete Mathematics: An Open Introduction (CC BY-SA 4.0). Condensed and re-explained here; errors are ours.
Zambiri pa Combinatorics & Graph Theory
The counting principlesPigeonhole principle and inclusion–exclusionBinomial coefficients and Pascal's triangleRecurrences and generating functionsGraphs: vertices, edges, degreesPaths, cycles, trees, Euler and HamiltonColouring and planar graphs