advanced practice · coding problem
MLE for Bernoulli trials
n=100 Bernoulli trials, 55 successes. Write the likelihood L(p)=p^55(1−p)^45, take log, differentiate, and solve for p̂. Why is this the same as the sample proportion?
The mechanism
MLE picks the parameter values that maximize the probability of what you actually saw. Log-likelihood turns products into sums — easier to optimize. Minimizing cross-entropy on classification data is MLE under a Bernoulli/categorical model.
Expected evidence
p̂=55/100=0.55. Log-likelihood derivative gives successes/n — MLE equals the intuitive estimator here.
Try this drill in the practice workspace →
Hints when you need them
- log L = 55 log p + 45 log(1−p) + const.
- Set d/dp = 0.
Watch for these mistakes
- Maximizing likelihood on training data with no regularization (overfitting)
- Forgetting that MLE is a point estimate, not uncertainty
- Mixing up likelihood P(data|θ) with probability of θ