Thirty draws from a standard normal are fitted by maximum likelihood with three location-scale families. Then a few outliers are added. The Gaussian fit (sample mean and standard deviation) is dragged towards the outliers and its scale inflates; the Laplace fit (sample median and mean absolute deviation) barely moves; the Student fit, found by EM for a chosen number of degrees of freedom ν, down-weights each outlier by w = (ν+1)/(ν+z2) and stays near the bulk unless ν is large, when it turns into a Gaussian. The right panel sweeps the outlier position and shows each location estimate.
The first 30 points are fixed (a seeded standard-normal sample); outliers are the position plus 0.3 times fixed standard-normal noise. The Gaussian and Laplace fits are closed form, the Student fit is EM with ν fixed (E step: weights w; M step: weighted mean and variance). Heavy-tailed models pay for robustness with a slightly lower likelihood on clean data.
code/ch02_probability_univariate.py (fit_gauss, fit_laplace, fit_student_em); the fits shown here equal the Python ones.