Least-Squares Visualizer

To use this tool you must be using a modern browser. See the list of supported browsers.

To begin, enter your data as two columns below. Then click on the Start button below.

Use the slider to change the values for m and b. The goal for least-squares to to find values that make E2 as small as possible.

m:
b:
E2=
Show Error Boxes:

The following button uses the formula for the least-squares line.


Help for Least Squares Visualizer X

First of all, I have made a short video that goes through a simple example using this tool. You can find the video here.

This tools is used to help understand and visualize the method of least-squares regression.

To begin, you need a data set which consists of a number of points with x values and y values. Enter this data set in the textbox in the upper right with each point on its own line (no commas or parentheses). For example

1 2
2 3
4 4
5 5 
8 10

Next, click the start button. You should see the points plotted on the axes on the left side of the screen. (Note: some points may not scale right on the axes. Just a little bug to be squashed.)

Running the Least-Squares Visualizer

There are two ways to run the least-squares visualizer: in manual mode and in automatic mode.

Manual Mode

If you click on the manual tab, you will see two sliders, one for m, the slope of the line and a slider for b, the y-intercept for the line. You can slide each slider to change the features of the line. Each point is plotted as a black dot and the square of each residual is plotted as a square (in light red) that connects the dot and the blue line.

There is also a value of E2 which is the sum of the squares of the residual (the area of the boxes). The goal of find the best least-square (or regression) line is to find the m and b that minimizes the value of E2.

Auto Mode

To switch to this mode, click on the "auto" tab on the right side of the screen. This mode finds the values of m and b that minimizes E2. Click on the button "Find the least-squares line" and up will pop m, b and E2. Also a purple line will appear on the plot with the given slope and intercept.