當前位置: 首頁>>代碼示例>>Python>>正文


Python ArmaProcess.generate_sample方法代碼示例

本文整理匯總了Python中statsmodels.tsa.arima_process.ArmaProcess.generate_sample方法的典型用法代碼示例。如果您正苦於以下問題:Python ArmaProcess.generate_sample方法的具體用法?Python ArmaProcess.generate_sample怎麽用?Python ArmaProcess.generate_sample使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在statsmodels.tsa.arima_process.ArmaProcess的用法示例。


在下文中一共展示了ArmaProcess.generate_sample方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_from_model

# 需要導入模塊: from statsmodels.tsa.arima_process import ArmaProcess [as 別名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import generate_sample [as 別名]
    def test_from_model(self):
        process = ArmaProcess([1, -.8], [1, .3], 1000)
        t = 1000
        rs = np.random.RandomState(12345)
        y = process.generate_sample(t, burnin=100, distrvs=rs.standard_normal)
        res = ARMA(y, (1, 1)).fit(disp=False)
        process_model = ArmaProcess.from_estimation(res)
        process_coef = ArmaProcess.from_coeffs(res.arparams, res.maparams, t)

        assert_equal(process_model.arcoefs, process_coef.arcoefs)
        assert_equal(process_model.macoefs, process_coef.macoefs)
        assert_equal(process_model.nobs, process_coef.nobs)
        assert_equal(process_model.isinvertible, process_coef.isinvertible)
        assert_equal(process_model.isstationary, process_coef.isstationary)
開發者ID:cong1989,項目名稱:statsmodels,代碼行數:16,代碼來源:test_arima_process.py

示例2: ArmaProcess

# 需要導入模塊: from statsmodels.tsa.arima_process import ArmaProcess [as 別名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import generate_sample [as 別名]
arma_t.isinvertible()

# <codecell>

arma_t.isstationary()

# <rawcell>

# * What does this mean?

# <codecell>

fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot(111)
ax.plot(arma_t.generate_sample(size=50));

# <codecell>

arparams = np.array([1, .35, -.15, .55, .1])
maparams = np.array([1, .65])
arma_t = ArmaProcess(arparams, maparams)
arma_t.isstationary()

# <codecell>

arma_rvs = arma_t.generate_sample(size=500, burnin=250, scale=2.5)

# <codecell>

fig = plt.figure(figsize=(12,8))
開發者ID:spel-uchile,項目名稱:SeismicScripts,代碼行數:32,代碼來源:ss_arma_model.py

示例3: ArmaProcess

# 需要導入模塊: from statsmodels.tsa.arima_process import ArmaProcess [as 別名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import generate_sample [as 別名]
        axes[3].set_ylabel('Irregular')

        fig.tight_layout()
        return fig


if __name__ == "__main__":
    import numpy as np
    from statsmodels.tsa.arima_process import ArmaProcess
    np.random.seed(123)
    ar = [1, .35, .8]
    ma = [1, .8]
    arma = ArmaProcess(ar, ma, nobs=100)
    assert arma.isstationary()
    assert arma.isinvertible()
    y = arma.generate_sample()
    dates = pd.date_range("1/1/1990", periods=len(y), freq='M')
    ts = pd.TimeSeries(y, index=dates)

    xpath = "/home/skipper/src/x12arima/x12a"

    try:
        results = x13_arima_analysis(xpath, ts)
    except:
        print("Caught exception")

    results = x13_arima_analysis(xpath, ts, log=False)

    # import pandas as pd
    # seas_y = pd.read_csv("usmelec.csv")
    # seas_y = pd.TimeSeries(seas_y["usmelec"].values,
開發者ID:DevSinghSachan,項目名稱:statsmodels,代碼行數:33,代碼來源:x13.py

示例4: MA

# 需要導入模塊: from statsmodels.tsa.arima_process import ArmaProcess [as 別名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import generate_sample [as 別名]
,
0.8
,
0.8
2
,
0.8
3
,
…
Simulate 5000 observations of the MA(30) model
Plot the ACF of the simulated series
'''



# import the modules for simulating data and plotting the ACF
from statsmodels.tsa.arima_process import ArmaProcess
from statsmodels.graphics.tsaplots import plot_acf

# Build a list MA parameters
ma = [0.8**i for i in range(30)]

# Simulate the MA(30) model
ar = np.array([1])
AR_object = ArmaProcess(ar, ma)
simulated_data = AR_object.generate_sample(nsample=5000)

# Plot the ACF
plot_acf(simulated_data, lags=30)
plt.show()
開發者ID:shonkhochil,項目名稱:Coursera-Repo,代碼行數:33,代碼來源:08-equivalance-of-ar(1)-and-ma(infinity).py

示例5: ArmaProcess

# 需要導入模塊: from statsmodels.tsa.arima_process import ArmaProcess [as 別名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import generate_sample [as 別名]
100XP
Import the class ArmaProcess in the arima_process module.
Plot the simulated AR procesees:
Let ar1 represent an array of the AR parameters [1, −ϕ
−
ϕ
] as explained above. For now, the MA parmater array, ma1, will contain just the lag-zero coefficient of one.
With parameters ar1 and ma1, create an instance of the class ArmaProcess(ar,ma) called AR_object1.
Simulate 1000 data points from the object you just created, AR_object1, using the method .generate_sample(). Plot the simulated data in a subplot.
Repeat for the other AR parameter.
'''
# import the module for simulating data
from statsmodels.tsa.arima_process import ArmaProcess

# Plot 1: AR parameter = +0.9
plt.subplot(2,1,1)
ar1 = np.array([1, -0.9])
ma1 = np.array([1])
AR_object1 = ArmaProcess(ar1, ma1)
simulated_data_1 = AR_object1.generate_sample(nsample=1000)
plt.plot(simulated_data_1)

# Plot 2: AR parameter = -0.9
plt.subplot(2,1,2)
ar2 = np.array([1, 0.9])
ma2 = np.array([1])
AR_object2 = ArmaProcess(ar2, ma2)
simulated_data_2 = AR_object2.generate_sample(nsample=1000)
plt.plot(simulated_data_2)
plt.show()
開發者ID:shonkhochil,項目名稱:Coursera-Repo,代碼行數:32,代碼來源:01-simulate-ar(1)-time-series.py


注:本文中的statsmodels.tsa.arima_process.ArmaProcess.generate_sample方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。