美文网首页python爬虫
Hurst指数与R/S(python代码)

Hurst指数与R/S(python代码)

作者: d33911380280 | 来源:发表于2018-08-19 13:39 被阅读99次

    -- 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指数与R/S(python代码)

        本文链接:https://www.haomeiwen.com/subject/drjmuttx.html