anova(一更)

import tushare as ts

from anova import Anova
gd=ts.get_hist_data(start='2018-01-01',code='600795')#国电电力
hd=ts.get_hist_data(start='2018-01-01',code='600726')#华电能源
#gd=gd.loc[:,'close']
###############################
print(Anova(gd)) 
def Anova(factor):
    import numpy as np
    import pandas as pd
    m=len(factor.columns)
    n=len(factor.index)
    fmean=factor.mean()    
    totalmean=fmean.mean()/m
    fstd=factor.std()
    sse=(fstd.sum())*n
    ssb=np.array(fmean)
    ssb=np.power(ssb-totalmean,2)*n
    ssb=pd.Series(ssb)
    ssb=ssb.sum()
    F=ssb*(n-m)/(sse*(m-1))
    return F
    

 

作者:隐

你可能感兴趣的:(参数假设检)