FunctionRacerProblemsRace

Fit the Growth Curve

HardSciPyPython

Sales of a new product follow an S-shaped curve: y = L / (1 + exp(-k * (t - m))), where L is the level it flattens out at, k the steepness and m the time of fastest growth. Given sales ys at times ts, return the best fitting [L, k, m]. Start the search from [max(ys), 1, median of ts]. Answers within 0.1% are accepted.

Example 1

ts [0,1,2,3,4,5,6,7,8,9,10]
ys [0.67,1.8,4.74,11.92,26.89,50.0,73.11,88.08,95.26,98.2,99.33]
returns [100.0,1.0,5.0]

The data were made with a level of 100, a steepness of 1 and the fastest growth at time 5.

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 SciPy problems