I've never been the best with combinatorics, but I could always at least get by. I thought of a problem that has really sparked an interest with me, though.

(I will start with a specific example, then move on to generalize)

Say you are doing laundry and get to the part where you are matching socks. Assume that you have 4 pairs of white socks, 3 pairs of black socks, 2 pairs of red socks, and 1 pair of yellow socks. You proceed to match socks in the following way:

You start with all of the socks in a basket (and every sock has a matching pair!). You randomly pull the first sock out and lay it in front of you. One at a time, you randomly pull each sock from the basket and do one of two things. If there is no sock laying in front of you that matches that sock, you also lay it in front of you. However, if there is a sock laying in front of you that matches it, you put those two together and put them away into your drawer. (Here, we assume that any two white socks will match each other, any two black sock will match each other, etc.)

What is the expected value of the largest number of socks you will have in front of you throughout this entire process?

To generalize, say we have \(a_1\) pairs of socks of the first color, \(a_2\) pairs of socks of the second color, up to \(a_n\) pairs of socks of the \(n\)th color, and you match your socks by the same method described above. What is the expected value of the largest number of socks you will have laying in front of you for this process? Is there a general method to determine this expected value?

I have attempted this question myself, but find my mediocrity within the subject of Combinatorics to prove to strong for me to work with more than 3 different colors of socks. Any help?

## Comments

Sort by:

TopNewestThanks for sharing! I've found that some of my favorite combinatorics and expected value problems come from pondering situations like this...

I haven't worked it out, but here's a framework that I suspect will help:

colorswhich appear anoddnumber of times in socks \(1,2,\ldots,k\)You could use this framework to construct a probability function for \(X_k.\) In other words, for all \(k,\) what is the probability that \(X_k = 0,1,2,\ldots, n\)? (It can't exceed \(n\) since you can't have more than 1 unpaired sock per color.)

However, you are looking for the expected value of the

maximum\(X_k.\) This gets a bit trickier because the \(X_k\) aren't independent, so having their individual distributions won't get you directly to the EV of the maximum \(X_k.\)That being said... I think this general framework is still probably useful. After \(k\) socks, there is some subset of colors \(C\) which are unpaired, so \(X_k = |C|.\) Then, after \(k+1\) socks, \(X_{k+1} = X_{k} - 1\) if the color of the \(k+1\) sock was in \(C\) and \(X_{k+1} = X_{k} + 1\) otherwise. Maybe stringing together the \(X_k\) in this way will give better insights into the distribution of the maximum value.

Anyone have ideas for next steps or an alternate approach? :) – Eli Ross Staff · 1 year, 3 months ago

Log in to reply

– Anthony Kirckof · 1 year, 3 months ago

Another approach (that I started, but didn't get to work too much with) would be writing a recursion for each case. Like, writing the number of situations of sock size \(n\) with largest size \(k\) as a function of situations of smaller socks and other largest sizes. Again, I need to find time to actually work out with that kind of calculation.Log in to reply

I think, the largest value would be n, in case the first n socks chosen are all different by color.Indeed, it's a very rare case, but the number of socks laying in front of you can't be more than n, because the (n+1)'st sock's color would mach one from the others(Dirchlet's theorem) – Imi Mali · 1 year, 3 months ago

Log in to reply

– Anthony Kirckof · 1 year, 3 months ago

While that is true, my question is asking what the expected value for the largest number is. That is, over all possible orders of choosing socks, what is the average of each "largest number" in each case.Log in to reply

– Imi Mali · 1 year, 3 months ago

that's indeed a more difficult question to answerLog in to reply