Model for Counts
Each y[i] is a count (0, 1, 2, ...) and x[i] a measurement that may drive it. Fit a Poisson regression of y on x with an intercept, as a generalized linear model, and return [intercept, slope]. Answers within 0.01% are accepted.
Example 1
x [0,1,2,3,4,5,6,7,8,9]
y [1,0,2,1,3,2,5,4,8,7]
returns [-0.2948623508469409,0.26840399789393454]
The counts roughly double every few steps of x, which a Poisson model captures with a positive slope on the log scale.
Constraints
10 <= len(x) <= 60- The xs are not all equal, and not every count is 0
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More statsmodels problems
- Odds of YesMedium
- Pattern in the LeftoversMedium
- Point That Pulls HardestMedium
- Tangled PredictorsMedium
- Top of the CurveMedium
- Trust Some Points MoreMedium
- Uneven SpreadMedium
- Do the Effects CombineHard