FunctionRacerProblemsRace

Point That Pulls Hardest

MediumstatsmodelsPython

Fit an ordinary least squares line to the points (x[i], y[i]). Return the index of the point with the largest Cook's distance: the one whose removal would move the fitted line the most.

Example 1

x [1,2,3,4,5,20]
y [2,4,6,8,10,5]
returns 5

The last point sits far to the right and far below the trend of the others.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More statsmodels problems