Explain Why a Geometric Mean Can Exceed Its Median
StackAdaptMachine Learning Engineer · Technical ScreenLast 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
-
Derive the Expected Value
E[X]: Show how to computeE[X]in terms ofp, either via direct summation or using the memoryless property / law of total expectation. -
Derive the Median
m: Define the median as the smallest integermsuch thatP(X = 0.5. Derive a closed-form formula formin terms ofpusing ceiling notation. -
Explain the Mean-Median Discrepancy:
- Explain why
E[X] >= mgenerally holds, detailing how the right tail impacts the mean versus the median. - Determine the exact value of
E[X]andmwhenp = 1. - Using the inequality
-ln(1 - p) p, show why the unrounded continuous thresholdln(0.5) / ln(1 - p)relates to1 / p.
- Explain why
-
Alternate Parameterization: Consider the alternate definition
Y = X - 1, representing the number of failures before the first success (Y in {0, 1, 2, ...}). How doE[Y]and the median ofYcompare?
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?
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.