All problems
Lag Selection Autocorr
Problem
Select the lag with the strongest absolute sample autocorrelation for lags 1..max_lag, using the biased estimator. Ties keep the smallest lag.
Return 1 when the series is constant (zero variance); return 0 for fewer than three points or max_lag < 1.
Hint
The strongest autocorrelation suggests the most useful lagged input.
Test cases
case 1
in: [[1,2,3,4,5],3]
expected: 1
case 2
in: [[1,2,1,2,1,2],4]
expected: 1
case 3
in: [[5,5,5,5],3]
expected: 1
case 4
in: [[1,2,3],3]
expected: 2
Starter codePython
def lag_selection_autocorr(series, max_lag):
# Your code here
pass4 test cases · run your code against them in the editor