如何在只有行和列的 python 中使用卡方 table?
How to use chi square table in python with only row and column?
我想知道如何从 spicy 库或任何其他库中获取卡方 table 的值?
例子:
我想要 row = 1
和 column = 0.05
:
的值
然后我收到图中显示的值 = 3.8415
或者有其他方式获取吗?
from scipy.stats import chisquare
row = 1
column = 0.05
print( chisquare(( row, column )) )
输出
Power_divergenceResult(statistic=0.8595238095238096, pvalue=0.35387198439864465)
期望的输出:
3.8415
您要问的是如何查找具有已知“自由度”值(图像中的行)和“显着性水平”(图像中的列)的卡方临界值。
您可以使用 scipy.stats.chi2.ppf()
方法完成此操作:
from scipy.stats import chi2
deg_f = 1
sig = 0.05
# find critical value
chi2.ppf(1-sig, deg_f)
# 3.841458820694124
我想知道如何从 spicy 库或任何其他库中获取卡方 table 的值?
例子:
我想要 row = 1
和 column = 0.05
:
然后我收到图中显示的值 = 3.8415
或者有其他方式获取吗?
from scipy.stats import chisquare
row = 1
column = 0.05
print( chisquare(( row, column )) )
输出
Power_divergenceResult(statistic=0.8595238095238096, pvalue=0.35387198439864465)
期望的输出:
3.8415
您要问的是如何查找具有已知“自由度”值(图像中的行)和“显着性水平”(图像中的列)的卡方临界值。
您可以使用 scipy.stats.chi2.ppf()
方法完成此操作:
from scipy.stats import chi2
deg_f = 1
sig = 0.05
# find critical value
chi2.ppf(1-sig, deg_f)
# 3.841458820694124