FunctionRacerProblemsRace

Fit the Decay

MediumSciPyPython

A signal fades as y = a * exp(-b * t). Given measurements ys at times ts, return the [a, b] that fit them best in the least squares sense. Answers within 0.1% are accepted.

Example 1

ts [0,1,2,3,4]
ys [4.0,2.426,1.472,0.893,0.541]
returns [3.9999522419366995,0.49993066367026284]

The data were made with a = 4 and b = 0.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