Katkat

Model wins-until-failure and expected future wins

WaymoData Scientist · Onsite

Last 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).

  1. Derive the Maximum Likelihood Estimator (MLE) for p based on the observed sequence of wins.
  2. Suppose a new player has already achieved k consecutive 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 >= 1
  • x_i >= 0
  • Assume p is 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?