hurst代码 python_Hurst指数与R/S(python代码)

-- coding: utf-8 --

"""

Created on Mon Oct 31 21:39:30 2016

@author: Administrator

"""

import numpy as np

x=data

data2=[]

for i in range(1,len(x)):

data1= x[i] - x[i-1]

data2.append(data1)

mdata=[]

for i in range(len(data2)):

m=np.mean(data2[:i+1])

mdata.append(m)

r=[]

for i in range(len(mdata)):

print('.......')

c=[]

b=[]

for j in range(0,i+1):

p=data2[j]-mdata[i]

c.append(p)

print(c)

b.append(np.cumsum(c)[-1])

r.append(max(b)-min(b))

sdata=[]

for i in range(len(data2)):

std=np.std(data2[:i+1])

sdata.append(std)

v = list(map(lambda x: x[0]/x[1], zip(r, sdata)))

rs=np.log(v)

t=np.array(range(1,11))/2

g=np.polyfit(np.log(t)[1:],rs[1:],1)

rt=pow(2,(2*g[0]-1))-1

你可能感兴趣的:(hurst代码,python)