All problems
Drift Estimate from Differences
Problem
Estimate the drift of a series as the mean of its first differences. Because the differences telescope, this equals (x[-1] - x[0]) / (n - 1).
Return 0.0 when the series has fewer than two observations.
Hint
Drift is the average step size of the random walk with drift model.
Test cases
case 1
in: [[1,3,5,7]]
expected: 2
case 2
in: [[10,10,10]]
expected: 0
case 3
in: [[5]]
expected: 0
case 4
in: [[1,3,2]]
expected: 0.5
Starter codePython
def drift_estimate(series):
# Your code here
pass4 test cases · run your code against them in the editor