bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Data Interview Question

Socks Pairing Probability

bugfree Icon

Hello, I am bugfree Assistant. Feel free to ask me for any question related to this problem

Solution & Explanation

The problem at hand is a classic probability puzzle that involves determining the expected number of sock withdrawals needed to obtain a matching pair from a drawer containing an infinite supply of two distinct colors of socks.

Problem Breakdown:

  • Socks Colors: Let's assume the two colors are Black (B) and White (W).
  • Objective: To find the expected number of draws required to get a matching pair of socks.

Approach:

  1. Understand the Possible Outcomes:

    • When drawing two socks:
      • BB: Both socks are black (matching pair)
      • WW: Both socks are white (matching pair)
      • BW: One sock is black, and the other is white (non-matching pair)
      • WB: One sock is white, and the other is black (non-matching pair)
  2. Calculate Probabilities:

    • Probability of getting a matching pair in two draws (either BB or WW):
      • P(BB) = P(WW) = 1/4 each
      • Total probability for matching pair in two draws = P(BB) + P(WW) = 1/4 + 1/4 = 1/2
    • Probability of getting a matching pair in three draws:
      • If the first two draws are BW or WB, the third sock will necessarily form a matching pair with one of the first two socks.
      • Therefore, the probability of needing three draws is the complement of getting a match in two draws, which is also 1/2.
  3. Calculate Expected Number of Draws (E):

    • Expected value formula for discrete random variables:

      E=i=1niP(ni)E = \sum_{i=1}^{\infty} n_i \cdot P(n_i)

    • For our case:

      E=2(12)+3(12)E = 2 \cdot \left(\frac{1}{2}\right) + 3 \cdot \left(\frac{1}{2}\right)

      E=1+1.5=2.5E = 1 + 1.5 = 2.5

Conclusion:

The expected number of individual sock withdrawals required to obtain a matching pair is 2.5. This result stems from the equal likelihood of needing either two or three draws to achieve a match, given the uniform distribution of sock colors.