tests whether the medians of data1 and data2 are equal.


tests the median difference against μ0.


returns the value of "property".

Details and Options

  • MannWhitneyTest performs a hypothesis test on data1 and data2 with null hypothesis that the true median difference against that .
  • By default, a probability value or -value is returned.
  • A small -value suggests that it is unlikely that is true.
  • The data in dspec can be univariate {x1,x2,} or multivariate {{x1,y1,},{x2,y2,},}.
  • The argument μ0 can be a real number or a real vector with length equal to the dimension of the data.
  • MannWhitneyTest assumes that the data is elliptically symmetric about a common spatial median in the multivariate case.
  • MannWhitneyTest[dspec,μ0,"HypothesisTestData"] returns a HypothesisTestData object htd that can be used to extract additional test results and properties using the form htd["property"].
  • MannWhitneyTest[dspec,μ0,"property"] can be used to directly give the value of "property".
  • Properties related to the reporting of test results include:
  • "DegreesOfFreedom"the degrees of freedom used in a test
    "PValue"list of -values
    "PValueTable"formatted table of -values
    "ShortTestConclusion"a short description of the conclusion of a test
    "TestConclusion"a description of the conclusion of a test
    "TestData"list of pairs of test statistics and -values
    "TestDataTable"formatted table of -values and test statistics
    "TestStatistic"list of test statistics
    "TestStatisticTable"formatted table of test statistics
  • For univariate samples MannWhitneyTest performs the MannWhitney -test for median differences of independent samples. A correction for ties is applied for both asymptotic and permutation-based -values. By default, the test statistic is corrected for continuity and is assumed to follow a NormalDistribution.
  • For multivariate samples, MannWhitneyTest performs an extension of the MannWhitney -test using spatial ranks. The test statistic is assumed to follow a ChiSquareDistribution[dim] where dim is the dimension of dspec.
  • The following options can be used:
  • AlternativeHypothesis "Unequal"the inequality for the alternative hypothesis
    MaxIterations Automaticmax iterations for multivariate median tests
    Method Automaticthe method to use for computing -values
    SignificanceLevel 0.05cutoff for diagnostics and reporting
  • For the MannWhitneyTest, a cutoff is chosen such that is rejected only if . The value of used for the "TestConclusion" and "ShortTestConclusion" properties is controlled by the SignificanceLevel option. By default, is set to 0.05.


open allclose all

Basic Examples  (2)

Test whether the medians of two independent populations differ:

The median difference :

At the 0.05 level, the medians are significantly different:

Compare the locations of multivariate populations:

The median difference vector :

At the 0.05 level, is not significantly different from {1,2}:

Scope  (9)

Testing  (6)

Test versus :

The -values are generally small when the locations are not equal:

The -values are generally large when the locations are equal:

Test versus :

The order of the datasets affects the test results:

Test whether the median difference vector of two multivariate populations is the zero vector:

Alternatively, test against {1,0,-1,0}:

Create a HypothesisTestData object for repeated property extraction:

The properties available for extraction:

Extract some properties from a HypothesisTestData object:

The -value and test statistic:

Extract any number of properties simultaneously:

The -value and test statistic from a MannWhitney test:

Reporting  (3)

Tabulate the test results:

Retrieve the entries from a test table for customized reporting:

Tabulate -values or test statistics:

The -value from the table:

The test statistic from the table:

Options  (10)

AlternativeHypothesis  (3)

A two-sided test is performed by default:

Test versus :

Perform a two-sided test or a one-sided alternative:

Test versus :

Test versus :

Test versus :

Perform tests with one-sided alternatives when μ0 is given:

Test versus :

Test versus :

MaxIterations  (2)

Set the maximum number of iterations to use for multivariate tests:

By default, 250 iterations are allowed:

Setting the maximum number of iterations may result in lack of convergence:

The -values are not equivalent:

Method  (4)

By default, -values are computed using asymptotic test statistic distributions:

Permutation methods can be used:

Set the number of permutations to use:

By default, random permutations are used:

Set the seed used for generating random permutations:

SignificanceLevel  (1)

The significance level is used for "TestConclusion" and "ShortTestConclusion":

Applications  (3)

Test whether the medians of some populations are equal:

The medians of the first two populations are similar:

The median of the third population is different from the first:

It has been observed that the duration of Old Faithful geyser eruptions is proportional to the time elapsed since the previous eruption:

Assuming one hour is a long wait for an eruption, test the statement that long waits lead to long eruption durations:

Two hundred Australian crabs were collected, and five morphological measures were taken for each crab. The data is organized by type and gender:

Determine if there is a difference in the first four morphological measures for the two varieties:

Compare the morphological measures across the genders:

Properties & Relations  (5)

For univariate data, the test statistic follows a NormalDistribution[0,1] under :

A large sample approximation to the NormalDistribution:

For multivariate data, the test statistic follows a ChiSquareDistribution[dim] under :

The test statistic is computed by pooling and ranking the data:

In the absence of ties, Ordering can compute the ranks:

The MannWhitney test ignores the time stamps when the input is a TimeSeries:

The MannWhitney test recognizes the path structure of a TemporalData with exactly two paths:

Use the values directly:

Neat Examples  (1)

Compute the statistic when the null hypothesis is true:

The test statistic given a particular alternative:

Compare the distributions of the test statistics:

Wolfram Research (2010), MannWhitneyTest, Wolfram Language function,


Wolfram Research (2010), MannWhitneyTest, Wolfram Language function,


Wolfram Language. 2010. "MannWhitneyTest." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2010). MannWhitneyTest. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_mannwhitneytest, author="Wolfram Research", title="{MannWhitneyTest}", year="2010", howpublished="\url{}", note=[Accessed: 20-July-2024 ]}


@online{reference.wolfram_2024_mannwhitneytest, organization={Wolfram Research}, title={MannWhitneyTest}, year={2010}, url={}, note=[Accessed: 20-July-2024 ]}