When I take a load of laundry from the dryer, there are socks mixed in with all of the other clothes. Suppose that there are pairs of socks, socks in total, that I match and fold by randomly drawing one sock at a time from the basket. If the sock matches one that I have already drawn, I fold the matching pair and put it away in the sock drawer. Otherwise, I set the unmatched sock aside, anticipating matching it later. How much space does this take? That is, let be the maximum number of unmatched socks set aside at any point during this process. What is the distribution of ?
There are at least a couple of different possible problems here, depending on what constitutes a matching pair of socks. Arguably the most natural setup is that all pairs are distinct (e.g., each pair of my dress socks is a different color), so that each individual sock has exactly one mate. This is what has been described as the sock matching problem in the literature; see the references below.
My athletic socks, on the other hand, are essentially identical pairs, with each individual sock being distinguished only by a “left” or “right” label stitched into it, so that each sock may be matched with any of the other “differently-handed” socks. In this case, it’s a nice problem to show that
But what I found most interesting about this problem is that appears to be very well approximated by , with an error that I conjecture is always less than 1/2, and approaches zero in the limit as grows large. I don’t see how to prove this, though.
[Edit 2021-02-20: It turns out that the above conjecture is incorrect; thanks to Michael Earnest, who in the comments shows that the expected value is in fact , referencing an interesting paper by de Bruijn, Knuth, and S. O. Rice. Interestingly, that constant multiplier in the term is approximately 1.22857, slightly larger than my incorrect guess of which is about 1.22474. Thanks, Michael!]