I am trying to test Hurst exponent in different time lag range. However, i got negative values in some time lag range which is weird, because the Hurst exponent should have values within the range from 0 to 1.
This is the Python code to calculate the Hurst exponent:
*calculate Hurst* lag1 = 2 lags = range(lag1, 20) tau = [sqrt(std(subtract(ts[lag:], ts[:-lag]))) for lag in lags] plot(log(lags), log(tau)); show() m = polyfit(log(lags), log(tau), 1) hurst = m*2 print 'hurst = ',hurst
Is there something wrong with the code or anyone know any good package to test hurst exponent in R or python?