Explanations and other information
This applet was prepared for my talk ("Least Squares Regression, Geometry, and Symmetry") at the 2004 Miami University Mathematics and Statistics Conference: Given a set of points {(x1,y1), (x2,y2), ... (xn,yn)}, the usual least-squares regression line y = a x + b is the one which minimizes the sum of the squared vertical distances from the points to the line. Why do we use (a) squared and (b) vertical distance? How does the equation change when we seek to minimize the sum of squared horizontal distances? Perpendicular distances? What about other ways of measuring distance?

With this applet, you can explore the effects of these different distance functions on the appearance of the "regression" line. Click to add new points—up to 50—or to delete or move existing points. If there are at least two points, the "best fit" line will be drawn, for whichever distance function you have chosen. Also shown as a blue dot is the point (x-bar, y-bar); for all "squared" distance functions, the line must pass through this point.

Added March 7, 2005: "Rotate points" option. When this option is selected, the first click sets the center of rotation (thereafter shown as a red dot), after which dragging the mouse rotates all points about that center. (Note that this can result in points moving off the edge of the visible region.)

(If you do not see the buttons in the applet, try reloading this page.)
I plan to add:
  • display of point coordinates as they are being moved,
  • the ability to display of more than one line at once (some distance functions yield multiple "best lines"),
  • better handling of vertical and near-vertical lines (which are sometimes best for horizontal and perpendicular distances, or when all points have the same x coordinate).
Please send suggestions for additional features to me.

Your browser does not support Java, so nothing is displayed.