All problems
Variogram Value
Problem
Compute the empirical variogram at lag h: 0.5 times the mean squared difference (x[t+h] - x[t])^2 over all valid t.
Return 0.0 when h is not positive or h is at least the series length.
Hint
The variogram measures half the expected squared change at a given lag.
Test cases
case 1
in: [[1,2,3,4,5],1]
expected: 0.5
case 2
in: [[1,3,5,7],2]
expected: 8
case 3
in: [[5,5,5],1]
expected: 0
case 4
in: [[1,2,3],5]
expected: 0
Starter codePython
def variogram_value(series, h):
# Your code here
pass4 test cases · run your code against them in the editor