Compare Mean and Median for a Distribution with a Point Mass
Company: Hudson
Role: Data Scientist
Category: Statistics & Math
Difficulty: medium
Interview Round: Technical Screen
Let the observations be independent samples from a distribution with unknown location parameter `mu`. Each observation equals `mu` with probability 0.2; otherwise, with probability 0.8, it is drawn from a normal distribution with mean `mu` and variance 1.
Compare estimation of `mu` using the sample mean and the sample median, including simulation and a finite-sample error probability.
### Constraints and Clarifying Questions
- Treat the 20% component as an exact point mass, not as a narrow normal distribution.
- The component probabilities and normal variance are known. The component label of an observation is not supplied to the estimator.
- For odd sample sizes, use the middle order statistic as the median. For even sample sizes, use the average of the two middle order statistics.
- Use mean absolute error, `E[abs(estimate - mu)]`, for the estimator comparison. Distinguish an exact calculation, an approximation, and a simulation estimate.
### Part 1 — Choose and Explain an Estimator
Given `n` observations, explain how to estimate `mu`. Compare the sample mean and sample median, including the effect of the point mass on their behavior.
#### What This Part Should Cover
- The population center and what symmetry does and does not imply about finite-sample error.
- The sample mean's variability and the median's possibility of equaling `mu` exactly.
- The sample-size and median-convention considerations needed to make the comparison precise.
### Part 2 — Compare Mean Absolute Error by Simulation
Write a simulation that compares the two estimators on the same generated samples. Explain the outputs and how to assess Monte Carlo uncertainty. Include `n = 80` as a comparison case.
#### What This Part Should Cover
- Correct sampling from the mixture, repeated independent datasets, and absolute errors for both estimators.
- A reproducible experiment, a clear MAE estimate, and uncertainty in the comparison.
- Checks that would reveal accidental removal of the point mass or use of the wrong error definition.
### Part 3 — Calculate a Tail Probability
For `n = 80`, calculate `P(abs(estimate - mu) > 0.1)` for the sample mean and sample median. Give exact expressions where feasible, explain any numerical approximation, and relate the result to the simulation.
#### What This Part Should Cover
- A finite-sample calculation for the mean and an order-statistic calculation for the median.
- Correct treatment of the atom and the average of the two central observations.
- A defensible comparison of the two tail probabilities, with numerical or analytic checks.
```hint Separate the random mechanisms
Track the number of observations drawn from each component. For the median, also consider how many observations lie below and above a proposed threshold.
```
### What a Strong Answer Covers
- A consistent definition of the estimators, loss, and threshold event.
- Reasoning that accounts for the point mass throughout the simulation and calculations.
- Clear limits on approximations, with no unsupported claim that all symmetric distributions favor the same estimator.
### Follow-up Questions
- What changes if the reported observations are rounded and repeated values can come from the continuous component?
- How would the calculation change if the lower middle observation were used as the even-sample median?
- Why is a continuous-density asymptotic formula for the median unreliable at the point mass?
Overview: Compare mean and median estimation for a point-mass and normal mixture using MAE simulation, finite-sample formulas, and error probabilities at sample size 80.