Model wins-until-failure and expected future wins
WaymoData Scientist · OnsiteLast updated
This question tests your ability to model geometric distributions and apply maximum likelihood estimation (MLE) to censored data.
Problem Statement
In a competitive video game, players engage in a challenge mode where they continue playing matches until they lose. Each match is an independent event where a player has a constant probability p of winning.
Let X be the number of consecutive wins a player achieves before their first loss. This follows a geometric distribution where the probability of winning is p and the probability of losing is 1 - p.
You are given a dataset containing the observed number of wins for n players: [x_1, x_2, ..., x_n]. Note that for every player, the sequence ended because they lost their last match (the data is complete, not censored).
- Derive the Maximum Likelihood Estimator (MLE) for
pbased on the observed sequence of wins. - Suppose a new player has already achieved
kconsecutive wins. Based on your estimator, what is the expected number of additional wins they will achieve before their first loss?
Example
- Input:
wins = [2, 0, 1] - Total wins = 3, Total games played = 6 (3 wins + 3 losses)
- Estimated
p= 3 / 6 = 0.5 - If a new player has 2 wins, expected additional wins = 1
Constraints
n>= 1x_i>= 0- Assume
pis in the interval(0, 1)
Hints
Hint 1
Write the likelihood function as a product of geometric probabilities: `P(X=k) = (p^k) * (1-p)`.
Hint 2
Take the log-likelihood of the product and find the derivative with respect to `p` to solve for the peak.
Hint 3
Recall the memoryless property of the geometric distribution: the future performance of a player is independent of their past performance.
Follow-up questions
- How does the estimation change if the data is right-censored (e.g., some players are still playing and have not lost yet)?
- If you suspect that `p` varies significantly between different players, how would you modify your model to account for this heterogeneity?
- How would you construct a confidence interval for `p` if the sample size `n` is very small?
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.