简体   繁体   English

默认情况下,来自scipy.stats的卡方值的自由度= 0。 这是什么意思?

[英]Chi square value from scipy.stats has degree of freedom = 0 as default. What does this mean?

Hi I have data sets (maxwellian and gaussian) that I make a histogram plot with. 嗨,我有一些数据集(麦克斯韦和高斯),可以用来做直方图。 I fit the data using scipy.stats.chisquare but it has by default, degrees of freedom as 0. If I understand correctly, it is not possible right? 我使用scipy.stats.chisquare拟合数据,但默认情况下其自由度为0。如果我理解正确,那不可能吗? 在此处输入图片说明

To directly answer your question, you are correct - Degrees of freedom being 0 is invalid/useless. 要直接回答您的问题,您是正确的-自由度为0无效/无用。 scipy.stats.chisquare parameter isn't degrees of freedom but an adjustment to degrees of freedom. scipy.stats.chisquare参数不是自由度,而是对自由度的调整。 Degrees of freedom defaults to k - 1 when ddof = 0. k can be directly determined from the data you pass to the chisquare function. 当ddof = 0时,自由度默认为k - 1 。可以直接根据传递给chisquare函数的数据确定k

From the Scipy chiqsuare documentation Scipy chiqsuare文档中

ddof : int, optional “Delta degrees of freedom”: adjustment to the degrees of freedom for the p-value. ddof:int,可选的“ Delta自由度”:调整p值的自由度。 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。

ddof is the delta not the absolute value for degrees of freedom. ddof增量而不是自由度的绝对值。 So degrees of freedom is k - 1 and ddof is an adjustment subtracted from k - 1. So when ddof = 0, degrees of freedom = k - 1 - 0 or k - 1 . 因此,自由度为k-1,而ddof是从k-1减去的调整量。因此,当ddof = 0时,自由度= k - 1 - 0 1-0或k - 1 When ddof = 1, degrees of freedom = k - 1 - 1 or k - 2 . 当ddof = 1时,自由度= k - 1 - 1k - 2 k is the number of observed frequencies and the chisquare function can determine that from the data you pass k是观察到的频率数, chisquare函数可以根据您传递的数据确定

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

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