From a shared server in June 2021, a conversation about probability and skittles.
"ive got a giant bag of skittles and im just grabbing handfuls and laying them on my desk to eat from instead of picking from the bag
the last 4 handfuls ive gotten have had perfect pairs of colors
for example, 2 green, 2, blue, 2 orange
or 2 blue, 2 purple, 2 red, 2 yellow
every single time"
"i wonder what the chances of that are"
To clarify the problem, we will assume:
- There are an infinite number of skittles in the bag, equally divided among 5 colours (Red, Orange, Yellow, Blue, and Purple).
- The probability of drawing a skittle of a particular colour is 1/5, and this remains true as we continue drawing skittles.
- We want to find the chance that a draw of 2 skittles forms 1 pair, a draw of 4 skittles forms 2 pairs, and a draw of 10 skittles forms 5 pairs.
Other formulations should be easy to derive from these solutions.
There are a few different ways that this can be solved.
Solution
Drawing 1 pair - inspection
We can calculate the probability of drawing a pair of skittles with the same colour by rephrasing this as the probability that the 2nd skittle drawn has the same colour as the 1st. This is 1/5, or 20%.
Drawing 2 pairs - case analysis
The 1st skittle can be any colour. The 2nd skittle can also be any colour, but its colour is important for the next draws.
- If the 2nd skittle's colour matches the 1st: (1/5 probability)
- the 3rd skittle can be any colour except the matching colour (4/5 probability), and
- the 4th skittle must match the third skittle's colour (1/5 probability).
- If the 2nd skittle's colour doesn't match: (4/5 probability)
- the 3rd skittle must match either the 1st or 2nd skittle's colour (2/5 probability), and
- the 4th skittle must match the remaining skittle (1/5 probability).
The resulting probability is thus (1/5 * 4/5 * 1/5) + (4/5 * 2/5 * 1/5) = 12/125, or 9.6%.
Drawing 5 pairs - combinatorics (and simulation)
Since there are only 5 colours, we must draw some ordering of RROOYYBBPP.
If each skittle was unique, there would be 10! = 10 * 9 * 8 * ... * 1 ways to order them, since there are 10 options to choose for the 1st element, then 9 options to choose for the 2nd (for each choice of the first element), etc.
However, note that we can swap each pair while creating the same ordering. For example, swapping the two B's in BPBYOORYPR doesn't create a new ordering. We must divide by 2! (the number of ways that duplicates can be reordered) five times to remove all the duplicated swaps, once for each colour.
Therefore, there are 10!/(2!^5) = 113400 ways to draw 5 pairs of skittles.
The total number of ways to draw 10 skittles is 5^10. For each draw, there are 5 equally likely possibilities of the skittle's colour, and we draw 10 times independently.
Therefore, there are 5^10 = 9765625 ways to draw 10 skittles.
Thus, the probability of drawing 5 pairs is 113400 / 9765625 = 0.01161.., or about 1.16%.
We can double-check this by writing a program that simulates the situation many times and seeing the number of times that 5 pairs are drawn.
(defn draw [] (repeatedly 10 #(rand-int 5))) (defn pairs5 [draws] (every? #(= % 2) (map second (frequencies draws)))) (frequencies (repeatedly 1000000 #(pairs5 (draw)))) ;; {false 9883746, true 116254}
The proportion is approximately 0.01163, which is fairly close to our theoretical result!