You are viewing a single comment's thread. Return to all comments →
Since we can't use any of imports, we will have to go basic and solve this using slope and intercept formulaes. Here is my code.
physics = [15 , 12 , 8 , 8 , 7 , 7 , 7 , 6 , 5 , 3] history = [10 , 25 , 17 , 11 , 13 , 17 , 20 , 13 , 9 , 15] xy = sum([x*y for x,y in zip(physics , history)]) xmean = sum(physics) / len(physics) ymean = sum(history) / len(history) x_2 = sum([x*x for x in physics]) numerator = xy - ymean*(sum(physics)) denominator = x_2 - xmean*(sum(physics)) slope = numerator/denominator intercept = ymean - slope*xmean prediction = slope*10 + intercept print("%.2f" %prediction)
Seems like cookies are disabled on this browser, please enable them to open this website
Correlation and Regression Lines - A quick recap #3
You are viewing a single comment's thread. Return to all comments →
Since we can't use any of imports, we will have to go basic and solve this using slope and intercept formulaes. Here is my code.