import scipy.stats as st import numpy as np from scipy.stats.distributions import f as fdist econ = [41,45,42,62,68,54,52,55,44,60] mgt = [74,74,70,52,76,91,71,78,76,78,83,50,52,66,65,53,72] print("Data Frame of econ is : ",f'\n{econ}\n') print("Data Frame of mgt is : ", f'\n{mgt}\n') v_econ = np.var(econ, ddof=1) v_mgt = np.var(mgt, ddof=1) print("Variance of econ is : ",v_econ) print("Variance of mgt is : ", v_mgt) F = v_mgt / v_econ print("Calculated F-statistic is : ",F) df1 = len(mgt) - 1 df2 = len(econ) - 1 print("df of numerator is :", df1) print("df of denominator is :", df2) #p_F = 1-st.f.cdf(F, df1, df2) #p_F #print("Probability of Right-Hand-Side of Calculated F-statistic is : ",p_F) F_1 = fdist.ppf(0.95, df1, df2) F_1 print("Value of F Distribution w/ df1=16 & df2=9 under 5% significance level is : ",F_1) #p_F_1 = 1-st.f.cdf(F_1, df1, df2) #p_F_1 #print("Probability of Right-Hand-Side of F_1 statistic is : ",p_F_1) #alpha = 0.05 #p_value = 1-st.f.cdf(F, df1, df2) #if p_value > alpha: # print("H_0 rejected") #else: # print("H_0 not rejected")