Logo
Section 1 / 5

随机过程

了解随机过程与确定性过程的区别,以及为什么随机过程在时间序列分析中至关重要。

导入

随机过程

了解随机过程与确定性过程的区别,以及为什么随机过程在时间序列分析中至关重要。

...
1import pandas as pd 2import matplotlib.pyplot as plt 3 4def deterministic(initial_state, steps): 5 ''' 6 该函数接收一个确定性系统的初始值和步数,返回经过这些步数后系统的一系列实现结果。 7 系统的值是初始值在最终步骤时的幂次结果。 8 参数: 9 :initial_state: 整数 10 :steps: 整数 11 ''' 12 counter = 0 13 state = initial_state 14 realisations = [] 15 while counter <= steps: 16 state = 2 * state 17 realisations.append(state) 18 counter += 1 19 20 return realisations 21 22results = deterministic(2, 10) 23s = pd.Series(results) 24 25plt.plot(s) 26plt.xlabel('步数') 27plt.ylabel('系统值') 28plt.show()
...
美国季度GDP
1import numpy as np 2import pandas as pd 3import matplotlib.pyplot as plt 4 5def random_walk(initial_state, steps): 6 ''' 7 该函数接收一个初始值和步数,计算在这些步数结束时的一系列随机游走实现结果。 8 随机游走由标准正态分布定义。 9 参数: 10 :initial_state: 整数 11 :steps: 整数 12 ''' 13 counter = 0 14 state = initial_state 15 realisations = [] 16 while counter <= steps: 17 state = state + np.random.normal(0, 1) 18 realisations.append(state) 19 counter += 1 20 return realisations 21 22results = random_walk(0, 10) 23s = pd.Series(results) 24 25plt.plot(s) 26plt.xlabel('步数') 27plt.ylabel('系统值') 28plt.show()

时间序列简介

递归与平稳性