Fit the Decay
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
5 <= len(ts) <= 300 <= ts[i] <= 5- The true
ais between 1 and 10 and the truebbetween 0.2 and 2
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More SciPy problems
- Is the Mean DifferentMedium
- Lowest PointMedium
- Nearest Point to Each QueryMedium
- Range for the MeanMedium
- Two Groups ComparedMedium
- Where It Crosses ZeroMedium
- Chains of Close PointsHard
- Fish in the LakeHard