简体   繁体   English

在scipy找到卡方检验的自由度?

[英]Find degrees of freedom for Chi square test in scipy?

I have a maxwellian distribution observation that I fit to expected maxwellian distribution. 我有一个麦克斯韦分布观测,我符合预期的麦克斯韦分布。 Then I run a chi square test to find out the goodness of the fit. 然后我进行卡方检验以找出合适的优点。 I get excellent results however, I also want to find out the degrees of freedom that the chi square test uses. 然而,我得到了很好的结果,我也想找出卡方测试使用的自由度。 To quote the documentation chisquare 引用文档chisquare

: The p-value is computed using a chi-squared distribution with k - 1 - ddof degrees of freedom, where k is the number of observed frequencies. :使用具有k-1-ddof自由度的卡方分布计算p值,其中k是观察到的频率的数量。 The default value of ddof is 0. ddof的默认值为0。

What is k exactly here? 这里的k到底是什么? Is it the total number of data points (41000) that I have? 它是我拥有的数据点总数(41000)吗? Or is it the frequency per bin? 或者它是每箱的频率? 在此输入图像描述

k is the size of f_obs , the first argument of chisquare . k是大小f_obs ,的第一个参数chisquare It is the number of bins. 这是箱子的数量。

For example, in the following example from the docstring, 例如,在docstring的以下示例中,

>>> chisquare([16, 18, 16, 14, 12, 12])
(2.0, 0.84914503608460956)

f_obs is [16, 18, 16, 14, 12, 12] , and k is len(f_obs) , or 6. f_obs[16, 18, 16, 14, 12, 12] f_obs [16, 18, 16, 14, 12, 12]klen(f_obs)或6。

The docs follow typical statistical variable names. 文档遵循典型的统计变量名称。 K-1 is the degrees of freedom. K-1是自由度。 K represents the amount of samples of each size n. K表示每种尺寸n的样品量。 So in your words, frequency per bin. 所以用你的话说,每箱的频率。

Last paragraph of http://statistics.about.com/od/Inferential-Statistics/a/What-Is-A-Degree-Of-Freedom.htm reads: http://statistics.about.com/od/Inferential-Statistics/a/What-Is-A-Degree-Of-Freedom.htm的最后一段内容如下:

Another example of a different way to count the degrees of freedom comes with an F test. 计算自由度的另一种方法的另一个例子是F测试。 In conducting an F test we have k samples each of size n. 在进行F测试时,我们有k个样本,每个样本大小为n。 The degrees of freedom in the numerator is k - 1 and in the denominator is k(n - 1). 分子中的自由度为k-1,分母中的自由度为k(n-1)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM