Is the Slope Real
Fit an ordinary least squares line to the points (x[i], y[i]) and return the p-value of its slope: the chance of seeing a slope this far from 0 if x had no effect at all.
Example 1
x [0,1,2,3]
y [0,1,0,1]
returns 0.552786404500042
A p-value of about 0.55: a slope like this turns up easily by chance.
Constraints
4 <= len(x) <= 40- The xs are not all equal, and the points are not exactly on a line
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More statsmodels problems
- Prices for New RowsEasy
- Range for the SlopeEasy
- Two CausesEasy
- Better of Two ModelsMedium
- Chance of YesMedium
- Does One Change the OtherMedium
- Model for CountsMedium
- Odds of YesMedium