如何在python中生成整数正AR(1)时间序列数据

时间:2019-06-12 13:25:56

标签: python-3.x time-series

我想生成一个全为正值的AR(1)整数时间序列数据。

我已经尝试过但是有这样的东西:array([0.43021319,-0.72313835,-2.41376921,-0.90018199,-0.47943723,...,-1.30406352])。

# Import modules
#import requests
import statsmodels.api as sm
#import io
import pandas as pd
import numpy as np

from matplotlib import pyplot as plt
from statsmodels.tsa.arima_model import ARIMA
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
import statsmodels.tsa.api as smtsa

# Function to plot signal, ACF and pacf
def plotds(xt,nlags=30, fig_size=(12, 10)):
    if not isinstance(xt, pd.Series):
        xt = pd.Series(xt)
    plt.figure(figsize=fig_size)
    layout = (2, 2)

    # Assign axes
    ax_xt = plt.subplot2grid(layout, (0, 0), colspan=2)
    ax_acf = plt.subplot2grid(layout, (1, 0))
    ax_pacf = plt.subplot2grid(layout, (1, 1))

    # Plot graphs
    xt.plot (ax=ax_xt)
    ax_xt.set_title('Time Series')
    plot_acf (xt, lags=50, ax=ax_acf)
    plot_pacf (xt, lags=50, ax=ax_pacf)
    plt.tight_layout ()
    return None

# Number os sample
n = 60

# Generate AR(1) dataset
ar = np.r_[1, -0.6]
ma = np.r_[1, 0]
ar1_data = smtsa.arma_generate_sample(ar=ar, ma=ma, nsample=n)

#print the data 
ar1_data

我想得到2位数字,整数和所有正数,例如23、25、22、12、10,...,89。

0 个答案:

没有答案