我们如何在scipy.stats.anderson_ksamp中传递两个数据集?有人可以举例说明吗?

icm*_*icm 5 python statistics scipy chi-squared statsmodels

Anderson函数仅询问一个参数,该参数应为一维数组。所以我想知道如何通过两个不同的数组进行比较吗?谢谢

CT *_*Zhu 5

将所有组放入一个list(在此示例中为两个数组或4个数组),然后将其传递给scipy.stats.anderson_ksamp

In [12]:

import scipy.stats as ss
#data from From the example given by Scholz and Stephens (1987, p.922)
x1=[38.7,  41.5,  43.8,  44.5,  45.5,  46.0,  47.7,  58.0]
x2=[39.2,  39.3,  39.7,  41.4,  41.8,  42.9,  43.3,  45.8]
x3=[34.0,  35.0,  39.0,  40.0,  43.0,  43.0,  44.0,  45.0]
x4=[34.0,  34.8,  34.8,  35.4,  37.2,  37.8,  41.2,  42.8]
ss.anderson_ksamp([x1,x2,x3,x4])
Out[12]:
(4.4797806271353506,
 array([ 0.49854918,  1.3236709 ,  1.91577682,  2.49304213,  3.24593219]),
 0.0020491057074350956)
Run Code Online (Sandbox Code Playgroud)

它返回3个值,1:归一化的k样本Anderson-Darling检验统计量,2:显着性水平的临界值25%,10%,5%,2.5%,1%。3:p值。

在此示例中,p值为0.002,我们得出结论,样本是从不同总体中得出的。