Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-341

OLS Slope Simple Regression

Problem

The ordinary least squares slope for one predictor is Sxy / Sxx summed over centered products and squares.

Given the predictor values and responses, return the slope.

Hint

Center both variables before forming the ratio.

Test cases

case 1
in: [[1,2,3],[2,4,6]]
expected: 2
case 2
in: [[0,1],[1,0]]
expected: -1
case 3
in: [[1,2,3,4],[1,3,2,5]]
expected: 1.1
Starter codePython
def ols_slope_simple_regression(xs, ys):
    # Your code here
    pass

3 test cases · run your code against them in the editor