naginterfaces.library.nonpar.test_​median

naginterfaces.library.nonpar.test_median(x, n1)[source]

test_median performs the Median test on two independent samples of possibly unequal size.

For full information please refer to the NAG Library document for g08ac

https://www.nag.com/numeric/nl/nagdoc_29.3/flhtml/g08/g08acf.html

Parameters
xfloat, array-like, shape

The first elements of must be set to the data values in the first sample, and the next () elements to the data values in the second sample.

n1int

The size of the first sample .

Returns
i1int

The number of scores in the first sample which lie below the pooled median, .

i2int

The number of scores in the second sample which lie below the pooled median, .

pfloat

The tail probability corresponding to the observed dichotomy of the two samples.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

Notes

In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.

The Median test investigates the difference between the medians of two independent samples of sizes and , denoted by:

and

where .

The hypothesis under test, , often called the null hypothesis, is that the medians are the same, and this is to be tested against the alternative hypothesis that they are different.

The test proceeds by forming a frequency table, giving the number of scores in each sample above and below the median of the pooled sample:

Sample 1

Sample 2

Total

Scores pooled median

Scores pooled median

Total

Under the null hypothesis, , we would expect about half of each group’s scores to be above the pooled median and about half below, that is, we would expect , to be about and to be about .

test_median returns:

  1. the frequencies and ;

  2. the probability, , of observing a table at least as ‘extreme’ as that actually observed, given that is true. If , is computed directly (‘Fisher’s exact test’); otherwise a approximation is used (see stat.contingency_table).

is rejected by a test of chosen size if .

References

Siegel, S, 1956, Non-parametric Statistics for the Behavioral Sciences, McGraw–Hill