Project 10: Predicting Y-Values
Intro Problem: Suppose we were interested in the relationship between how many AP classes a student is taking vs. how many absences the student has.
X = # of AP classes
Y = # of absences
Suppose x and y are the following arrays:
x = [2, 2, 0, 2, 4, 6]
y = [6, 8, 7, 4, 4, 1]
The scatterplot below represents 6 points formed by corresponding x and y values.
These points are: (2, 6), (2, 8), (0, 7), (2, 4), (4, 4), (6, 1)
The line of best (LSRL) is also shown. The equation for the LSRL is: Y = -1.5x + 9
Suppose we want the predicted value for a point with X = 6. We can see from the graph that y is predicted to be 0 when x = 6. We could also substitute x = 6 into the LSRL equation: Y = -1.5(6) + 9 = 0.
This would mean we predict a student taking 6 AP classes to have 0 absences.
Project 10: Variables x, y, and xVal have been initialized. There are also working methods called getM and getB.
x is the array of x-coordinates for the points in the dataset
y is the array of y-coordinates for the points in the dataset
Note: the length of x and y will be the same.
xVal is the x-coordinate of the point that we are predicting the y-coordinate for (6 in the example above)
getM(x,y) returns the slope of the line of best fit (-1.5 in the example above)
getB(x,y) returns the y-intercept of the line of best fit (9 in the example above)
Task: Appropriately initialize the value of 'predictedY' that corresponds to the predicted y-value for the given point.
**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