最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用python實(shí)現(xiàn)畫AR模型時(shí)序圖

 更新時(shí)間:2019年11月20日 09:29:56   作者:潛水的飛魚baby  
今天小編就為大家分享一篇使用python實(shí)現(xiàn)畫AR模型時(shí)序圖,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

背景:

用python畫AR模型的時(shí)序圖。

結(jié)果:

代碼:

import numpy as np
import matplotlib.pyplot as plt
"""
AR(1)的時(shí)序圖:x[t]=a*x[t-1]+e
"""
num = 2000
e = np.random.rand(num)
x = np.empty(num)
 
"""
平穩(wěn)AR(1)
"""
a = -0.5
x[0] = 2
for i in range(1,num):
 x[i] = a*x[i-1]+e[i]
plt.subplot(321,title = "AR({0}):x[t]={1}*x[t-1]+e".format(1,a))
plt.plot(x,"or")
 
"""
非平穩(wěn)AR(1)
"""
a = -1.01
x[0] = 2
for i in range(1,num):
 x[i] = a*x[i-1]+e[i]
plt.subplot(322,title = "AR({0}):x[t]={1}*x[t-1]+e".format(1,a))
plt.plot(x,".b")
 
"""
平穩(wěn)AR(2)
"""
a = -0.2
b = 0.7
x[0] = 2
for i in range(2,num):
 x[i] = a*x[i-1]+b*x[i-2]+e[i]
plt.subplot(323,title = "AR({0}):x[t]={1}*x[t-1]+{2}*x[t-2]+e".format(2,a,b))
plt.plot(x,"og")
 
"""
非平穩(wěn)AR(2)
"""
a = -0.3
b = 0.8
x[0] = 2
for i in range(2,num):
 x[i] = a*x[i-1]+b*x[i-2]+e[i]
plt.subplot(324,title = "AR({0}):x[t]={1}*x[t-1]+{2}*x[t-2]+e".format(2,a,b))
plt.plot(x,".y")
 
"""
非平穩(wěn)AR(2)
"""
a = -0.2
b = 0.8
x[0] = 2
for i in range(2,num):
 x[i] = a*x[i-1]+b*x[i-2]+e[i]
plt.subplot(313,title = "AR({0}):x[t]={1}*x[t-1]+{2}*x[t-2]+e".format(2,a,b))
plt.plot(x,"+",color="purple")
 
plt.show()

以上這篇使用python實(shí)現(xiàn)畫AR模型時(shí)序圖就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:

相關(guān)文章

最新評論

伽师县| 崇阳县| 苍山县| 镇坪县| 正镶白旗| 沾化县| 沾化县| 洪洞县| 平乐县| 株洲县| 将乐县| 晴隆县| 河西区| 铁岭市| 屯昌县| 忻州市| 西藏| 建水县| 阜新| 湖口县| 临朐县| 淮北市| 江门市| 修武县| 潼南县| 临湘市| 庄河市| 凉山| 沁源县| 乌兰县| 伊通| 宜章县| 娄烦县| 美姑县| 黄大仙区| 弥渡县| 上饶市| 拜泉县| 黑山县| 大同市| 锦州市|