Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-342

OLS Intercept Simple Regression

Problem

The OLS intercept is mean(y) - slope * mean(x), which anchors the fitted line at the sample means.

Given the predictor values and responses, return the intercept.

Hint

Substitute the means into y = a + b x.

Test cases

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

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