y = np.random.randn(20)
# This is another approximation to be sure the wavelet approx is close
h0 = eg.hurst(y)
w = pywt.Wavelet('db4')
c = pywt.wavedec(y, w)
levels = len(c)
D = []
for i in range(len(c)):
dj = 0
l = len(c[i])
for j in range(l):
dj += float(pow(c[i][j], 2))
D.append( dj / float(l) )
print D
slope,intercept=np.polyfit(np.log2(D),range(len(D)),1)
hurst = abs((slope-1)/float(2))
print(h)
print(hurst)