第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在單變量時間序列建模中生成觀測值

在單變量時間序列建模中生成觀測值

臨摹微笑 2023-10-31 14:38:40
我得到了單變量時間序列建模(自回歸模型)的過程。在這個過程中,我想使用 while 循環(huán)生成 100 個觀察結(jié)果。import numpy as np np.random.seed(17)T = 200alpha1 = 0.8alpha2 = 0.15u = np.random.randn(T)y = np.zeros (T)for t in np.arange(2,200):    y[t] = alpha1*y[t-1] + alpha2*y[t-2] + u[t]    y = y[100:]# Write a while loop which generates 100 observations from AR(2) defined above# This is my first try. However, it seems that I am initiating an infinite loop for some reason. Does anybody have a suggestion on how to generate 100 observations from the process described above?import numpy as npnp.random.seed(17)T = 200alpha1 = 0.8alpha2 = 0.15u = np.random.randn(T)y = np.zeros (T)t = 2while t <=102 :    y[t] = alpha1*y[t-1] + alpha2*y[t-2] + u[t]    y = y[:]    print(y)
查看完整描述

1 回答

?
catspeake

TA貢獻(xiàn)1111條經(jīng)驗 獲得超0個贊

您應(yīng)該while通過遞增t變量來結(jié)束循環(huán),否則它將始終等于 2。因此,您的while循環(huán)將如下所示:



# initialize y, alpha1y, alpha2y and u


t = 2

while t <= 102: # I prefer t < 103 (=102 + 1) for no reason at all

    y[t] = alpha1y[t-1] + alpha2y[t-2] + u[t]

    t += 1 # assuming you are moving one step at a time


查看完整回答
反對 回復(fù) 2023-10-31
  • 1 回答
  • 0 關(guān)注
  • 120 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號