How do we pass two datasets in scipy.stats.anderson_ksamp?Can anyone explain with an example?
Asked Answered
V

1

6

The anderson function asks only for one parameter and that should be 1-d array. So I am wondering how to pass two different arrays to be compared in it? Thanks

Veratridine answered 16/7, 2014 at 14:52 Comment(0)
L
9

Put all of the groups into one list (be it two arrays or 4 arrays in this example), and pass that to 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)

It returns 3 values, 1: Normalized k-sample Anderson-Darling test statistic., 2: The critical values for significance levels 25%, 10%, 5%, 2.5%, 1%., 3: the p-values.

In this example, p values is 0.002, we conclude the samples are drawn from different populations.

Leroi answered 17/7, 2014 at 18:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.