Least-Squares Analysis of Discrete Data