1
$\begingroup$

This was an interview question. Given a known distribution, sample a value from it with replacement for many times. Two people A and B bet on the sample with their own guesses, and the one closer to the actual sample value wins. What's your betting strategy?

The interviewer claimed the median value is better than mean. I didn't get it. Can someone explain? Thanks.

$\endgroup$
1
  • 2
    $\begingroup$ Try a simple example, such as a Bernoulli$(p)$ distribution. When $p\ne 1/2$ the median and mean differ, but it is easy to see which strategy is better and why. $\endgroup$
    – whuber
    May 22 at 12:32

2 Answers 2

1
$\begingroup$

The median minimizes expected absolute distance between observations sampled from the distribution and a single value. That is:

$$ \underset{m}{\text{min}}\text{ }\mathbb E\left[ \left\vert X - m\right\vert \right] = \text{median} $$

This is in contrast to the mean, which minimizes expected squared distance.

$$ \underset{m}{\text{min}}\text{ }\mathbb E\left[ \left( X - m\right)^2 \right] = \text{mean} $$

I think this is what the interviewer wanted to test if you knew.

$\endgroup$
1
  • $\begingroup$ This is the formal derivation I was looking for. Thank you! $\endgroup$
    – jesse
    May 23 at 20:49
2
$\begingroup$

The mean is affected by outliers in the distribution, so does not inform us about the mid-point of the distribution. The median is not affected by outliers.

Consider three example distributions and see how the presence of one outlier affects the mean but not the median:

Example Distribution Median Mean
1 [1, 2, 3, 4, 5] 3 3
2 [1, 2, 3, 4, 10] 3 4
3 [1, 2, 3, 4, 20] 3 6

So relating these examples back to your interview question: assume A picks the median, so 50% of the time the sample will be less than A's guess and 50% of the time greater. Therefore, if B picks a different value from A, A's guess must be closer to the sample value at least 50% of the time.

Now assume B picks the mean. In the first case, they pick the same number, so the outcome is a draw. In the second case, A wins 60% of the time, B wins 20% of the time and it's a draw 20% of the time. In the third case, A wins 80% of the time and B wins 20% of the time.

$\endgroup$
4
  • $\begingroup$ Re "Therefore, if B picks a different value from A, A's guess must be closer to the sample value at least 50% of the time:" why does this follow? It's not an obvious consequence of the definition of the median, which you haven't quite correctly characterized: it is not always the case that 50% of the time the sample will be less than the median. What you can say is that at least 50% of the time the value will be no greater than the median. $\endgroup$
    – whuber
    May 22 at 12:29
  • $\begingroup$ It makes sense that "50% of the time the sample will be less than A's guess and 50% of the time greater.", while I don't understand why "A's guess must be closer to the sample value at least 50% of the time." How did you derive that? $\endgroup$
    – jesse
    May 23 at 16:28
  • 1
    $\begingroup$ @jesse If B picks above A's guess, A is closer to all under-median samples, which are 50% of all possible samples. If B picks below A's guess, A is closer to all over-median samples, which also comprise 50% of all possible samples. No matter what side of A is picked by B, A is closer to at least half of all possible samples, so should be expected to win at least half the time (assuming B doesn't also pick the median). $\endgroup$ May 23 at 16:57
  • $\begingroup$ @NuclearHoagie Very clear explanation, Thank you! $\endgroup$
    – jesse
    May 23 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.