This situation happened to me at home today, and now it is bugging me. I didn't put all my clothes in the washing machine, and I retrieved 7 sockets, 2 pairs of socks and 3 unpaired ones.

I wanted to come up with the most likely number of pairs but I couldn't. I assume it is close to a binomial distribution but the pairing has made my life miserable.

My random variables are:

  • $\Theta$ pairs of socks
  • $n$ drawn socks
  • $2\cdot k$ paired socks

Is there a way to derive the close- form for $P(y|2\cdot \Theta)$?

  • $\begingroup$ Obligatory link: sumsar.net/blog/2014/10/tiny-data-and-the-socks-of-karl-broman $\endgroup$ – Tim Jun 1 at 12:04
  • $\begingroup$ @ Tim♦ the article is quite interesting. However, I want a closed form solution. Simulating for each $\Theta$ would be easy but I believe there is a closed for as I have one parameter less (no odd socks considered). $\endgroup$ – Jon Nagra Jun 1 at 12:19
  • $\begingroup$ Sure, I didn't say it does. $\endgroup$ – Tim Jun 1 at 12:37

$$ P(2k, n-2k| \Theta) = \frac{2^{n-2k} \binom{\Theta-k}{n-2k} \binom{\Theta}{k}}{\binom{2\Theta}{n}}.$$

Denominator - Unconstrained no. ways to choose socks

This is given exactly by the binomial coefficient to choose $n$ objects from $2\Theta$:


Numerator - No. ways to choose $k$ pairs

This is again a binomial coefficient: we want to choose $k$ pairs out of a set of $\Theta$:


Numerator - No. ways to choose the single socks

There remain $\Theta - k$ pairs of socks ,and we want to to choose $n-2k$ of these: as before the number of ways to choose the types of socks will be $\binom{\Theta-k}{n-2k}$.

However we now need to account for the fact that for each pair of socks there were two possible choices (eg. left/right foot). So for each type of sock we need to multiply by a factor of $2$, giving:

$$2^{n-2k} \binom{\Theta-k}{n-2k}$$


The above assumes that all of your socks go into the wash in pairs: note that this differs from Baath's assumption in the link that Tim provided, where he supposes that its possible that there are some single socks in the wash.

(Edited) As discussed in the comments when $k = 0$ the likelihood will be maximised as $\Theta \rightarrow \infty$. To get around this case you may wish to regularise by making assumptions about the reasonable expectations of the maximum (eg. what's the maximimum no. socks your machine could hold) - this is well suited to a Bayesian analysis where you would place a prior on $\Theta$. Again, Baath's post gives a good introduction.

Here's some half-baked notes I did on the explicit calculation for Baath's analysis: so far I've only posted the non-Bayesian bit.

| cite | improve this answer | |
  • 1
    $\begingroup$ Thanks a lot, it is really elegant. I'm not totally sure about your point on the maximisation of $\Theta$. Intuitevily if $k=0$ the max of $\Theta$ should be obtained at infinity whilst for $2k=n$ the max should be obtained on $\Theta=n$. I would include priors in a real exercise, but to my understanding your close solution is differentiable and can be maximised $\endgroup$ – Jon Nagra Jun 1 at 14:58
  • $\begingroup$ No problem. Good point - I was overly simplistic asserting the maximum would always be at infinity. I guess what I'm getting at is that it is not guaranteed to be finite. I'll update to clarify this. $\endgroup$ – owen88 Jun 1 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.