Problem bank

Problem 173 of 333MediumCodingP173

Catastrophic cancellation

  1. Computing the sample variance via Var=E[X2]−(E[X])2\text{Var} = E[X^2] - (E[X])^2 can fail in floating-point arithmetic for large means and small variance. Why, and what's the fix?