Skip to content

Instantly share code, notes, and snippets.

@marufeuille
Created January 28, 2020 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marufeuille/edaab09029043c429a32c11083c0d6ae to your computer and use it in GitHub Desktop.
Save marufeuille/edaab09029043c429a32c11083c0d6ae to your computer and use it in GitHub Desktop.
def generate(phi_1, phi_2, c, sigma, size):
# 期待値
mu = c/(1-phi_1-phi_2)
# 乱数のseedを固定
np.random.seed(17)
# データの生成
ar_data = np.zeros(size)
ar_data[0] = mu + np.random.normal(0, sigma)
ar_data[1] = mu + np.random.normal(0, sigma)
for t in range(2, size):
ar_data[t] = c + phi_1*ar_data[t-1] + phi_2*ar_data[t-2] + np.random.normal(0, sigma)
return ar_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment