Katkat

Explain Why a Geometric Mean Can Exceed Its Median

StackAdaptMachine Learning Engineer · Technical Screen

Last updated

Tests derivation and comparison of the expected value and median of a geometric distribution, explaining how right-skewness drives the mean above the median across different parameterizations.

Scenario

In digital advertising and conversion modeling, ad platforms often model the number of ad impressions required until a user converts as a discrete waiting-time problem using the geometric distribution.

Let X be a discrete random variable representing the trial number of the first success in repeated, independent Bernoulli trials with success probability p where 0 < p <= 1.

The probability mass function (PMF) is: P(X = k) = (1 - p)^(k - 1) * p for k = 1, 2, 3, ...

Tasks

  1. Derive the Expected Value E[X]: Show how to compute E[X] in terms of p, either via direct summation or using the memoryless property / law of total expectation.

  2. Derive the Median m: Define the median as the smallest integer m such that P(X = 0.5. Derive a closed-form formula for m in terms of p using ceiling notation.

  3. Explain the Mean-Median Discrepancy:

    • Explain why E[X] >= m generally holds, detailing how the right tail impacts the mean versus the median.
    • Determine the exact value of E[X] and m when p = 1.
    • Using the inequality -ln(1 - p) p, show why the unrounded continuous threshold ln(0.5) / ln(1 - p) relates to 1 / p.
  4. Alternate Parameterization: Consider the alternate definition Y = X - 1, representing the number of failures before the first success (Y in {0, 1, 2, ...}). How do E[Y] and the median of Y compare?

Hints

Hint 1

Recall that the cumulative distribution function (CDF) for the trials-to-first-success geometric distribution is F(k) = 1 - (1 - p)^k.

Hint 2

Solve 1 - (1 - p)^m >= 0.5 by taking natural logarithms on both sides, remembering to flip the inequality sign when dividing by ln(1 - p).

Hint 3

Use the standard inequality ln(1 - p) < -p for 0 < p < 1 to compare the continuous median approximation -ln(2) / ln(1 - p) directly with the mean 1/p.

Follow-up questions

  • How does the mean-median relationship here compare to the continuous exponential distribution with rate parameter lambda?
  • If an ad-tech pipeline has corrupted data with occasional massive outliers (e.g., bot traffic with thousands of views before conversion), would you prefer sample mean or sample median to monitor baseline user conversion delays?
  • What happens to the relative gap (E[X] - median(X)) / E[X] in the limit as p approaches 0?