# Socks which may or may not match

You just won 2016 socks. Some of them are white, some are blue. The color of each sock was randomly chosen, with a 50/50 probability. Is it more probable that the socks can be paired, or that you will remain with two unmatching socks?

• The problem may be solved in an interesting way, which does not involve calculations. BTW: do you know its original source? – mau Jun 4 '16 at 21:16
• I wear non-matching socks anyway. Sometimes on purpose! Like one michelangelo and one donatello, or an iron man and a captain america. I'm a grownup. – Brent Hackers Jun 5 '16 at 20:03

The probability of "pairability" is...

exactly 50%.
Consider what happens when all but one of the socks has been chosen. You'll have one color that has an even number of socks, and one that has an odd number. The last sock is equally likely to be either color: if it's the even color, then you'll have leftovers, and if it's the odd color, you'll be able to match every sock up.

Eeyup. Exactly 50% probability. To be able to match all the socks, we just have to get an even amount of both white and blue socks - or just white, since their total count is 2016 and if one is even, then so is the other. Pick all the socks at random except just one. You'll always have exactly one unfinished pair (with either of one blue or white extra sock). No matter how many socks we already have, it always reduces to just one of them, which could be blue or white with 50% probability. So, the total probability of having no unmatched pair is 50% too.

You can play around with this little program made to statistically verify the statement:

import random

def coin():
'A coinflip.'
return random.randint(0,1)==0

def coins(n):
'Amount of "0" coinflips for n tries.'
#In our case, amount of white socks out of N-total sock-pool (:3).
c = 0
for i in range(n):
c += 1 if coin() else 0
return c

def sockcheck(tries, n=2016):
# Socks are paired if (and only if) there are even amounts of both white and black socks.
# It's enough to just check for whites, of course.
# Let's see how often we'll get even amount of white socks!
assert n%2 == 0
wins = 0
for t in range(tries):
if coins(n) % 2 == 0:
wins+=1
print("{} successes of {}: {:%} probability.".format(wins, tries, wins/tries))

if __name__=='__main__':
print('Enter number of tries (200 seems legit):')
tries = int(input())
sockcheck(tries, 2016)


And the result is...

Enter number of tries (200 seems legit):
2016
1004 successes of 2016: 49.801587% probability.


Eeyup! Close enough.

• @DeFazer How do you define the word "exactly?" – Chowzen Jun 5 '16 at 15:53
• @Chowzen, "exactly" as in "exactly one" - not 2, not 3, not 0 - exactly 1. If that's not a correct usage of this word, feel free to correct me! Although I try my best to avoid writing mistakes, English is not my native language, so, sadly, I may be quite prone to making them. – DeFazer Jun 9 '16 at 15:02

There are two situations that matter when picking the last sock:

1) we have one extra of one sock.
- this is the situation mentioned by deusovi. 50% either way.

2) we have three extra of one sock.
- 50% we get the extra sock and we throw out the situation.
- 50% we get the lesser sock and we increase the probability of having one unmatched set.

Therefore we are more likely to have one unmatched set.

• Three extra of one sock? You can just make a pair. – Deusovi Jun 5 '16 at 4:26
• @Deusovi Bah. It's too late for me. This was silly. :p I was thinking you had to have a white and a blue for a pair. Looking at my feet it appears I'm still ok :) – LeppyR64 Jun 5 '16 at 4:28

This is a simplified for was a question on a probability test. Given 4 coins what is the most likely outcome when all 4 are tossed? The answer is 3 and 1! Here are the possible outcomes:

4 and 0 = two possibilities

2 and 2 = six possibilities

3 and 1 = eight possibilities

HHHH - HHHT - HHTH - HHTT - HTHH - HTHT - HTTH - HTTT - THHH - THHT - THTH - THTT - TTHH - TTHT - TTTH - TTTT

So in the sock question the process is the same, except we are only worry about pairs so the outcome is as said by everyone 50/50

• I think you counted incorrectly - you've listed 2 and 2 as having the most possibilities. – JBentley Jun 5 '16 at 15:08
• Oops sorry you are correct, 3 and 1 is reversed with 2 and 2. My mistake. – Gregory West Jun 6 '16 at 2:32

I believe that

EDIT:
**In the question, the statment: "with a 50/50 probability" could be related to EACH DRAW as opposed to a cumulative effect. I chose the cumulative approach:

The probability is that the color of the second-to-last sock chosen is unlikely to be chosen last. There are, in this scenario, more likely to be more of the other sock color available in the pool, so choosing two of the "second-to-last" color twice in a row is less likely than choosing one that is (in all reasonable probability) in greater supply. The socks are more likely to be paired. Doesn't matter if there are 2016 socks, 2,106,000 socks or just two socks. The probability is the same. The second sock is probably a different color.

• The problem specifically says that each sock has a 50% chance of being each color. Drawing from a pool would mean that each sock does not have a 50% chance of being each color. – Deusovi Jun 5 '16 at 4:26
• The "cumulative approach"? How would that make sense? The problem clearly states that each sock is equally likely to be either color. – Deusovi Jun 5 '16 at 6:47
• @Deusovi I guess I didn't interpret it correctly? Your options are Upvote / Downvote/ Ignore. There is no "Berate" button. – Chowzen Jun 5 '16 at 7:24