Project 9: Least Squares Regression Line

The above scatterplot shows the world record mile times for a span of over 100 years.  The line shown in the scatterplot is called the least squares regression line.  We oftentimes refer to this line as "the line of best fit".  We could use this line equation to predict the world record time in 2030 (although it probably would not be a good estimate here because this linear trend will not continue).


Below are the formulas for calculating the Least Squares Regression Line.

Project 9: Variables 'x' and 'y' have been initialized.  There are also working methods getAverage, getSD, and getR.

x and y are both arrays that hold the same number of values.

getAverage(a) returns the average of a.

getSD(a) returns the standard deviation of a.

getR(x, y) returns the correlation coefficient between x and y.

Task: Appropriately assign the variables 'm' and 'b' that represent the line of best fit (least squares regression line) between x and y.

The equation will be displayed, and the line will be graphed on the scatterplot.

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0