• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python stattools.acovf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中statsmodels.tsa.stattools.acovf函数的典型用法代码示例。如果您正苦于以下问题:Python acovf函数的具体用法?Python acovf怎么用?Python acovf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了acovf函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_acovf_fft_vs_convolution

def test_acovf_fft_vs_convolution(demean, unbiased):
    np.random.seed(1)
    q = np.random.normal(size=100)

    F1 = acovf(q, demean=demean, unbiased=unbiased, fft=True)
    F2 = acovf(q, demean=demean, unbiased=unbiased, fft=False)
    assert_almost_equal(F1, F2, decimal=7)
开发者ID:statsmodels,项目名称:statsmodels,代码行数:7,代码来源:test_stattools.py


示例2: test_acovf2d

def test_acovf2d():
    dta = sunspots.load_pandas().data
    dta.index = Index(dates_from_range('1700', '2008'))
    del dta["YEAR"]
    res = acovf(dta)
    assert_equal(res, acovf(dta.values))
    X = np.random.random((10,2))
    assert_raises(ValueError, acovf, X)
开发者ID:joesnacks,项目名称:statsmodels,代码行数:8,代码来源:test_stattools.py


示例3: test_acovf2d

def test_acovf2d():
    dta = sunspots.load_pandas().data
    dta.index = DatetimeIndex(start='1700', end='2009', freq='A')[:309]
    del dta["YEAR"]
    res = acovf(dta)
    assert_equal(res, acovf(dta.values))
    X = np.random.random((10,2))
    assert_raises(ValueError, acovf, X)
开发者ID:bert9bert,项目名称:statsmodels,代码行数:8,代码来源:test_stattools.py


示例4: test_acovf_nlags_missing

def test_acovf_nlags_missing(acovf_data, unbiased, demean, fft, missing):
    acovf_data = acovf_data.copy()
    acovf_data[1:3] = np.nan
    full = acovf(acovf_data, unbiased=unbiased, demean=demean, fft=fft,
                 missing=missing)
    limited = acovf(acovf_data, unbiased=unbiased, demean=demean, fft=fft,
                    missing=missing, nlag=10)
    assert_allclose(full[:11], limited)
开发者ID:statsmodels,项目名称:statsmodels,代码行数:8,代码来源:test_stattools.py


示例5: test_acovf2d

def test_acovf2d(reset_randomstate):
    dta = sunspots.load_pandas().data
    dta.index = date_range(start='1700', end='2009', freq='A')[:309]
    del dta["YEAR"]
    res = acovf(dta, fft=False)
    assert_equal(res, acovf(dta.values, fft=False))
    x = np.random.random((10, 2))
    with pytest.raises(ValueError):
        acovf(x, fft=False)
开发者ID:statsmodels,项目名称:statsmodels,代码行数:9,代码来源:test_stattools.py


示例6: levinson_durbin_nitime

def levinson_durbin_nitime(s, order=10, isacov=False):
    '''Levinson-Durbin recursion for autoregressive processes

    '''
    #from nitime

##    if sxx is not None and type(sxx) == np.ndarray:
##        sxx_m = sxx[:order+1]
##    else:
##        sxx_m = ut.autocov(s)[:order+1]
    if isacov:
        sxx_m = s
    else:
        sxx_m = acovf(s)[:order+1]  #not tested

    phi = np.zeros((order+1, order+1), 'd')
    sig = np.zeros(order+1)
    # initial points for the recursion
    phi[1,1] = sxx_m[1]/sxx_m[0]
    sig[1] = sxx_m[0] - phi[1,1]*sxx_m[1]
    for k in xrange(2,order+1):
        phi[k,k] = (sxx_m[k]-np.dot(phi[1:k,k-1], sxx_m[1:k][::-1]))/sig[k-1]
        for j in xrange(1,k):
            phi[j,k] = phi[j,k-1] - phi[k,k]*phi[k-j,k-1]
        sig[k] = sig[k-1]*(1 - phi[k,k]**2)

    sigma_v = sig[-1]; arcoefs = phi[1:,-1]
    return sigma_v, arcoefs, pacf, phi  #return everything
开发者ID:AnaMP,项目名称:statsmodels,代码行数:28,代码来源:try_ld_nitime.py


示例7: stationarity_convergence

def stationarity_convergence(phi):
    
        m = 20 # burn in 
        n = len(phi) - m
        if n <= 0:
                return 0
        na = max(1,int(0.1*n))
        nb = max(1,int(0.5*n))
        
        phi_a = phi[(m+n-na):(m+n)]
        phi_b= phi[(m):(m+nb)]
        phi_b= phi[(m+n-nb):(m+n)]
        
        phi_b_bar = sum(phi_b)/nb
        phi_a_bar = sum(phi_a)/na
        if len(phi_a) <= 1 or len(phi_b) <= 1:
                return 1
        
        v_a = acovf(phi_a)
        v_b = acovf(phi_b)
        
        # n gets large and na/n and nb/n stay fixed
        z_g = (phi_a_bar - phi_b_bar)/np.sqrt( v_a[0] + v_b[0] )
        return z_g
开发者ID:heidekrueger,项目名称:CaseStudiesMachineLearning,代码行数:24,代码来源:stochastic_tools.py


示例8: ar_generator






arrvs = ar_generator()
##arma = ARIMA()
##res = arma.fit(arrvs[0], 4, 0)
arma = ARIMA(arrvs[0])
res = arma.fit((4,0, 0))

print(res[0])

acf1 = acf(arrvs[0])
acovf1b = acovf(arrvs[0], unbiased=False)
acf2 = autocorr(arrvs[0])
acf2m = autocorr(arrvs[0]-arrvs[0].mean())
print(acf1[:10])
print(acovf1b[:10])
print(acf2[:10])
print(acf2m[:10])


x = arma_generate_sample([1.0, -0.8], [1.0], 500)
print(acf(x)[:20])
import statsmodels.api as sm
print(sm.regression.yule_walker(x, 10))

import matplotlib.pyplot as plt
#ax = plt.axes()
开发者ID:0ceangypsy,项目名称:statsmodels,代码行数:25,代码来源:example_arma.py


示例9: VARMA

    B[:,:,1] = [[0,0],[0,0],[0,1]]
    xhat5, err5 = VARMA(x,B,C)
    #print(err5)

    #in differences
    #VARMA(np.diff(x,axis=0),B,C)


    #Note:
    # * signal correlate applies same filter to all columns if kernel.shape[1]<K
    #   e.g. signal.correlate(x0,np.ones((3,1)),'valid')
    # * if kernel.shape[1]==K, then `valid` produces a single column
    #   -> possible to run signal.correlate K times with different filters,
    #      see the following example, which replicates VAR filter
    x0 = np.column_stack([np.arange(T), 2*np.arange(T)])
    B[:,:,0] = np.ones((P,K))
    B[:,:,1] = np.ones((P,K))
    B[1,1,1] = 0
    xhat0 = VAR(x0,B)
    xcorr00 = signal.correlate(x0,B[:,:,0])#[:,0]
    xcorr01 = signal.correlate(x0,B[:,:,1])
    print(np.all(signal.correlate(x0,B[:,:,0],'valid')[:-1,0]==xhat0[P:,0]))
    print(np.all(signal.correlate(x0,B[:,:,1],'valid')[:-1,0]==xhat0[P:,1]))

    #import error
    #from movstat import acovf, acf
    from statsmodels.tsa.stattools import acovf, acf
    aav = acovf(x[:,0])
    print(aav[0] == np.var(x[:,0]))
    aac = acf(x[:,0])
开发者ID:haribharadwaj,项目名称:statsmodels,代码行数:30,代码来源:varma.py


示例10: test_pandasacovf

def test_pandasacovf():
    s = Series(range(1, 11))
    assert_almost_equal(acovf(s), acovf(s.values))
开发者ID:joesnacks,项目名称:statsmodels,代码行数:3,代码来源:test_stattools.py


示例11: binLightCurve

            print "T = %i s, t = %3.2f ms"%(T,1000.*newInt)

        #try:
            bins, lc = binLightCurve(timeSpan[0],timeSpan[0]+T, times, newInt)
            lcAve = np.mean(lc)
            print "<I> = %4.2f"%lcAve
            lcVar = np.power(np.std(lc),2)
            print "sigma(I)^2 = %3.3f"%lcVar
            lcNorm = lc/lcAve
        
            #plot timestream with T total seconds binned into t=(n+1)*intTime integration time bins
            ax1.plot(bins,np.append(lcNorm,lcNorm[-1]),drawstyle='steps-post', label="%i s"%(T))

            print "Calculating auto-covariance sequence..."
            #acvs = acovf(lc,unbiased=True,demean=True) #* 1.0/(lcVar-lcAve)
            acvs = acovf(lc,unbiased=False,demean=False)

            #corr,ljb,pvalue = acf(lc,unbiased=True,qstat=True,nlags = T/newInt)
            corr,ljb,pvalue = acf(lc,unbiased=False,qstat=True,nlags = T/newInt)
            
            standalone_ljb, standalone_pvalue = acorr_ljungbox(lc)
        
            print "Min(p-value) of acf Ljung-Box test = %f"%np.min(pvalue)
            try:
                print "Min(p) of acf LB at index %i of %i"%(np.where(pvalue==np.min(pvalue))[0],len(pvalue))
                mostCorrLag = np.where(pvalue==np.min(pvalue))[0] * newInt*1000
                print "Min(p) of acf LB at lag = %4.3f ms"%mostCorrLag

            except TypeError:
                print "Min(p) of acf LB at index %i of %i"%(np.where(pvalue==np.min(pvalue))[0][0],len(pvalue))
                mostCorrLag = np.where(pvalue==np.min(pvalue))[0][0] * newInt*1000
开发者ID:srmeeker,项目名称:DarknessPipeline,代码行数:31,代码来源:speckleStats.py


示例12: acovf

    plt.plot(wm,sdm/sdm[0], '-', wm[maxind], sdm[maxind]/sdm[0], 'o')
else:
    plt.plot(wm, sdm, '-', wm[maxind], sdm[maxind], 'o')
plt.title('matplotlib')

if hastalkbox:
    sdp, wp = stbs.periodogram(x)
    plt.subplot(2,3,3)

    if rescale:
        plt.plot(wp,sdp/sdp[0])
    else:
        plt.plot(wp, sdp)
    plt.title('stbs.periodogram')

xacov = acovf(x, unbiased=False)
plt.subplot(2,3,4)
plt.plot(xacov)
plt.title('autocovariance')

nr = len(x)#*2/3
#xacovfft = np.fft.fft(xacov[:nr], 2*nr-1)
xacovfft = np.fft.fft(np.correlate(x,x,'full'))
#abs(xacovfft)**2 or equivalently
xacovfft = xacovfft * xacovfft.conj()

plt.subplot(2,3,5)
if rescale:
    plt.plot(xacovfft[:nr]/xacovfft[0])
else:
    plt.plot(xacovfft[:nr])
开发者ID:bashtage,项目名称:statsmodels,代码行数:31,代码来源:try_arma_more.py


示例13: test_acovf_warns

def test_acovf_warns(acovf_data):
    with pytest.warns(FutureWarning):
        acovf(acovf_data)
开发者ID:statsmodels,项目名称:statsmodels,代码行数:3,代码来源:test_stattools.py


示例14: test_acovf_error

def test_acovf_error(acovf_data):
    with pytest.raises(ValueError):
        acovf(acovf_data, nlag=250, fft=False)
开发者ID:statsmodels,项目名称:statsmodels,代码行数:3,代码来源:test_stattools.py


示例15: test_acovf_nlags

def test_acovf_nlags(acovf_data, unbiased, demean, fft, missing):
    full = acovf(acovf_data, unbiased=unbiased, demean=demean, fft=fft,
                 missing=missing)
    limited = acovf(acovf_data, unbiased=unbiased, demean=demean, fft=fft,
                    missing=missing, nlag=10)
    assert_allclose(full[:11], limited)
开发者ID:statsmodels,项目名称:statsmodels,代码行数:6,代码来源:test_stattools.py


示例16: test_pandasacovf

def test_pandasacovf():
    s = Series(lrange(1, 11))
    assert_almost_equal(acovf(s, fft=False), acovf(s.values, fft=False))
开发者ID:statsmodels,项目名称:statsmodels,代码行数:3,代码来源:test_stattools.py



注:本文中的statsmodels.tsa.stattools.acovf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python stattools.adfuller函数代码示例发布时间:2022-05-27
下一篇:
Python stattools.acf函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap