All problems
Hurst Exponent Lite
Problem
Estimate the Hurst exponent from the variance ratio with q = 2. Let d1 be the first differences and d2 the second-order differences of the series; compute v1 = mean(d1^2), v2 = mean(d2^2), then VR = v2 / (2 * v1) and H = log(VR) / log(2).
Return 0.0 if the series has fewer than three points or v1 is 0. H = 0.5 suggests a random walk, H > 0.5 trending, H < 0.5 mean-reverting.
Hint
The variance ratio is 2^H, so taking log base 2 recovers H.
Test cases
case 1
in: [[1,2,4,7,11]]
expected: 0.8831863350172501
case 2
in: [[3,3,3,3,3]]
expected: 0
case 3
in: [[1,2,3,4,5,6]]
expected: 1
case 4
in: [[2,4,6,8,10,12]]
expected: 1
Starter codePython
import math
def hurst_lite(series):
# Your code here
pass4 test cases · run your code against them in the editor