沪深指数和上证指数数据
import tushare as ts
import pandas as pd
hs300 = ts.get_hist_data('hs300',start='2016-01-02',end='2018-12-28')[['open','high','low','close']]
hs300_pct = hs300['close'].pct_change().dropna()
sz50 = ts.get_hist_data('sz50',start='2016-01-02',end='2018-12-28')['close']
sz50 = sz50.sort_index(axis=0,ascending = True)
sz50.index = sz50.index.astype(str)
sz50_pct = sz50.pct_change().dropna()
sz_hs = pd.merge(left=hs300_pct.to_frame() ,right=sz50_pct.to_frame(),left_index=True,right_index=True,suffixes=('_hs','_sz'))
kstest检验结果如下:
import scipy.stats as sct
sct.kstest(rvs=sz_hs.iloc[:,0],cdf='norm',args=(0,0.01))
输出结果:KstestResult(statistic=0.049822991141110037, pvalue=0.38735431533163411)
pvalue>1%接受原假设 说明服从(0.0.01^2)正态分布
sct.kstest(rvs=sz_hs.iloc[:,0],cdf='norm')
输出结果:KstestResult(statistic=0.4847020921233226, pvalue=0.0)
pvalue = 0 < 1%拒绝 说明不服从正态分布
那么到底服从吗??