python平稳性检验_Python数据分析0.3 用statsmodels进行ADF平稳性检验
#statsmodels用于數據的統計建模分析
#此例為ADF平穩性檢驗的例子
from statsmodels.tsa.stattools import adfuller as ADF
import numpy as np
#np.random.rand返回100個服從【0,1)之間均勻分布的隨機樣本值
'''
statsmodels.tsa.stattools.adfuller(
x, maxlag=None, regression='c', autolag='AIC', store=False, regresults=False)[source]?
x: 序列,一維數組
maxlag:差分次數
regresion:{c:只有常量,
ct:有常量項和趨勢項,
ctt:有常量項、線性和二次趨勢項,
nc:無任何選項}
autolag:{aic or bic: default, then the number of lags is chosen to minimize the corresponding information criterium,
None:use the maxlag,
t-stat:based choice of maxlag.
Starts with maxlag and drops a lag until the t-statistic on the last lag length is significant at the 95 % level.}
)'''
print(ADF(np.random.rand(100)))
結果為:(-11.132232301402519, 3.260491543071536e-20, 0, 99, {'1%': -3.498198082189098, '5%': -2.891208211860468, '10%': -2.5825959973472097}, 35.95266020626107)
-11.132232301402519<'1%'.val
原假設不成立,數據是平穩的。
總結
以上是生活随笔為你收集整理的python平稳性检验_Python数据分析0.3 用statsmodels进行ADF平稳性检验的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c++ post请求_前端工程师进阶:网
- 下一篇: python telnetlib详解 执