The Sock Drawer Paradox
I prompted Claude for a math puzzle and was suprised to see one that I did not know about. Figured it might be worth sharing here.
The Sock Drawer Paradox
You have a drawer with some red socks and some blue socks. You know that if you pull out 2 socks randomly, the probability they're both red is $\frac{1}{2}$
Given this information, what's the probability that the first sock you pull is red?
The Surprising Answer
Most people think "well if P(both red) = 1/2, then P(first red) should be set" but this problem has multiple solutions!
Let $r$ = number of red socks and $b$ = number of blue socks.
The probability of drawing two red socks is: $$P(\text{both red}) = \frac{r}{r+b} \times \frac{r-1}{r+b-1} = \frac{1}{2}$$
After symplifying and using the quadratic formula you get: $$r = b \pm 0.5 \sqrt{8.0 b^{2} + 1.0} + 0.5$$
This can be varified with sympy.
from sympy import symbols, Eq, solve
# Let r be the number of red socks and b be the number of blue socks
r, b = symbols('r b')
# The probability of pulling 2 red socks
probability_both_red = (r / (r + b)) * ((r - 1) / (r + b - 1))
# Given that this probability is 1/2
equation = Eq(probability_both_red, 1/2)
# Solve for r in terms of b
solution = solve(equation, r)
Integers
Not all of these solutions are integer solutions though. But you can find them via:
from sympy import lambdify
from decimal import Decimal
r_given_b = lambdify("b", solution[1])
[{"b": _, "r": int(r_given_b(_))}
for _ in range(1000000)
if (r_given_b(_) * 1000 % 1000) == 0]
There are 8 solutions in the first one million values for $b$.
b | r | $p(r)$ | $p(rr)$ |
---|---|---|---|
1 | 3 | 0.75 | 0.5 |
6 | 15 | 0.714286 | 0.5 |
35 | 85 | 0.708333 | 0.5 |
204 | 493 | 0.707317 | 0.5 |
1189 | 2871 | 0.707143 | 0.5 |
6930 | 16731 | 0.707113 | 0.5 |
40391 | 97513 | 0.707108 | 0.5 |
235416 | 568345 | 0.707107 | 0.5 |
What's interesting here is that the probability of grabbing a red ball converges as $b$ grows but it is not constant. There is still a degree of freedom when you only know the probability of grabbing two red balls!