Mean and Variance Through Maximum Likelihood
AmazonApplied Scientist · OnsiteLast updated
Derive the maximum likelihood estimators (MLE) for the mean and variance of a univariate Gaussian distribution, and analyze the bias of the resulting variance estimator.
Scenario
At Amazon, you are analyzing server latency metrics for a critical payment gateway service. Preliminary exploratory data analysis shows that latency measurements under steady-state traffic approximately follow a univariate normal (Gaussian) distribution.
Suppose you observe an independent and identically distributed (i.i.d.) sample of n continuous latency measurements: X = {x_1, x_2, ..., x_n}, where each x_i ~ Normal(mu, sigma^2) with unknown mean mu and unknown variance sigma^2 > 0.
Tasks
-
Likelihood & Log-Likelihood Construction: Write down the joint probability density function (likelihood function
L(mu, sigma^2)) of the sample, and compute the natural log-likelihood functionell(mu, sigma^2) = ln L(mu, sigma^2). -
Derive the MLE Estimators:
- Find the maximum likelihood estimator for
mu, denotedmu_hat_MLE. - Find the maximum likelihood estimator for
sigma^2, denotedsigma^2_hat_MLE. - Show your step-by-step calculus (partial derivatives set to zero) and justify that this critical point represents a maximum.
- Find the maximum likelihood estimator for
-
Bias Analysis of the Variance Estimator:
- Compute the expected value
E[sigma^2_hat_MLE]in terms of the true variancesigma^2and sample sizen. - State whether
sigma^2_hat_MLEis unbiased. If biased, explain intuitively why this bias occurs (degrees of freedom / estimation of the mean). - Show how to obtain the standard unbiased sample variance
s^2fromsigma^2_hat_MLE(Bessel's correction).
- Compute the expected value
Hints
Hint 1
Start by expressing the log of the product of Gaussian densities as a sum of individual log densities, separating terms dependent on mu and sigma^2.
Hint 2
When computing E[sigma^2_hat_MLE], rewrite (x_i - mu_hat) as ((x_i - mu) - (mu_hat - mu)) before expanding the squared term.
Hint 3
Recall that Var(mu_hat) = sigma^2 / n, which will help evaluate E[(mu_hat - mu)^2].
Follow-up questions
- Is the maximum likelihood estimator for the standard deviation, sigma_hat_MLE = sqrt(sigma^2_hat_MLE), an unbiased estimator of sigma?
- How does the Mean Squared Error (MSE) of sigma^2_hat_MLE compare to the MSE of the unbiased estimator s^2?
- Under a Bayesian framework with a conjugate normal-inverse-gamma prior, how do the posterior point estimates for mu and sigma^2 relate to the MLE solutions?
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.