When, why, and how to use weighted least squares