FunctionRacerProblemsRace

Model for Counts

MediumstatsmodelsPython

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

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