Line Through Zero
Some relationships must pass through the origin: no hours, no pay. Fit y = slope * x with no intercept by ordinary least squares and return the slope.
Example 1
x [1,2,3]
y [2,4,6]
returns 2.0
y is exactly twice x.
Constraints
2 <= len(x) <= 40- The xs are not all 0
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More statsmodels problems
- Line Through the DataBeginner
- Reading Off the LineBeginner
- Room for the InterceptBeginner
- Slope From a TableBeginner
- What the Line MissesBeginner
- Echo of YesterdayEasy
- Fair R SquaredEasy
- Group GapsEasy