Matlab 中的卡方独立性

chi square independence in Matlab

我们可以使用 MATLAB 进行 'chi square independence' 测试吗?如果是,我正在寻找 'reliable' 工作示例。 我没有尝试过,对此我也不熟悉。

是的。您可以使用文件交换中的函数:https://es.mathworks.com/matlabcentral/fileexchange/7143-chi-square-test-for-independence.

要执行测试,只需使用您的数据和间隔数调用函数 chi2test(data, numOfInterval)

示例代码

data = rand(1000, 1000);
num_int = 8;
chi2test(data, num_int);

x =
    5.6000

ans =
   14.0671

其中 x 是卡方独立性检验的结果 ans 是卡方累积分布函数的反函数,其中 num_int 自由度指定为 data.

中的相应概率

有关此功能的更多信息,请参阅[1]。

[1] 黄凯文 (2020)。卡方独立性检验 (https://www.mathworks.com/matlabcentral/fileexchange/7143-chi-square-test-for-independence),MATLAB 中央文件交换。 2020 年 4 月 12 日检索。