Find Expected Spins Until Two Regions Appear
SIG (Susquehanna)Data Scientist · Online AssessmentLast updated
This problem tests knowledge of expected value and geometric distributions by calculating the expected number of trials to observe two distinct outcomes from a discrete probability distribution.
The Problem
Imagine a spinner with three colored regions: Red (R), Blue (B), and Green (G). The probabilities of landing on each color in a single spin are fixed as follows:
- P(R) = 1/2
- P(B) = 1/4
- P(G) = 1/4
You spin the spinner repeatedly until you have observed at least two distinct colors. Calculate the expected number of spins required to satisfy this condition.
Example
If the sequence of spins is [R, R, B], you stop at the third spin because you have observed two distinct colors (Red and Blue). The number of spins is 3.
Formal Task
Let X be the random variable representing the number of spins until two distinct colors appear. Calculate E[X].
Considerations
- What is the probability of picking a "new" color given that you have already seen one?
- How does the expected value change depending on which color appears first?
- Ensure you account for the fact that a spin can result in the same color multiple times before a new color is observed.
Hints
Hint 1
Let E be the total expected number of spins, and consider conditioning on the outcome of the first spin.
Hint 2
If the first spin lands on a color with probability p, the number of additional spins needed is a geometric variable with success probability (1 - p).
Hint 3
Use the law of total expectation: E[X] = 1 + sum over colors i of [P(i) * E[X | first spin is i]].
Follow-up questions
- How would the expectation change if the probabilities were uniform (1/3, 1/3, 1/3)?
- Generalize the formula for N regions with probabilities p_1, p_2, ..., p_n.
- What is the expected number of spins required to observe all three distinct colors?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.