Odds of Yes
Each y[i] is 0 or 1 (no or yes), and x[i] is a measurement that may sway it. Fit a logistic regression of y on x with an intercept and return [intercept, slope]. Answers within 0.01% are accepted.
Example 1
x [-3,-2,-2,-1,-1,0,0,1,1,2,2,3,-1.5,0.5,1.5]
y [0,0,0,0,1,0,1,1,0,1,1,1,0,1,1]
returns [0.1815478429461524,1.3287569246438977]
Yes becomes more likely as x grows, so the slope is positive.
Constraints
15 <= len(x) <= 60- The yes and no cases overlap along
x
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More statsmodels problems
- Pattern in the LeftoversMedium
- Point That Pulls HardestMedium
- Tangled PredictorsMedium
- Top of the CurveMedium
- Trust Some Points MoreMedium
- Uneven SpreadMedium
- Do the Effects CombineHard
- Drop the Weak OnesHard