MannWhitneyTest
✖
MannWhitneyTest
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 - The following options can be used:
-
AlternativeHypothesis "Unequal" the inequality for the alternative hypothesis MaxIterations Automatic max iterations for multivariate median tests Method Automatic the method to use for computing -values
SignificanceLevel 0.05 cutoff for diagnostics and reporting - For univariate samples, MannWhitneyTest performs the Mann–Whitney
-test for median differences of independent samples. The following methods are available:
-
Automatic chooses depending on the size of the sample "Asymptotic" large sample statistic is asymptotically normally distributed "Exact" small sample values can be computed exactly
"Permutation" simulation based - For the "Asymptotic" and "Permutation" methods, a correction for ties is applied; the test statistic is corrected for continuity, and it is assumed to follow a NormalDistribution.
- For multivariate samples, MannWhitneyTest performs an extension of the Mann–Whitney
-test using spatial ranks. The test statistic is assumed to asymptotically follow a ChiSquareDistribution[dim] where dim is the dimension of dspec.
- 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.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Test whether the medians of two independent populations differ:

https://wolfram.com/xid/0b7ekgesiu28r68m-lq5ldd

https://wolfram.com/xid/0b7ekgesiu28r68m-soqc9


https://wolfram.com/xid/0b7ekgesiu28r68m-bolh4v

At the 0.05 level, the medians are significantly different:

https://wolfram.com/xid/0b7ekgesiu28r68m-csendg

Compare the locations of multivariate populations:

https://wolfram.com/xid/0b7ekgesiu28r68m-2lnxj
The median difference vector :

https://wolfram.com/xid/0b7ekgesiu28r68m-nj57pj


https://wolfram.com/xid/0b7ekgesiu28r68m-b6etdn

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

https://wolfram.com/xid/0b7ekgesiu28r68m-j55r4w

Scope (9)Survey of the scope of standard use cases
Testing (6)

https://wolfram.com/xid/0b7ekgesiu28r68m-ekpnsf
The -values are generally small when the locations are not equal:

https://wolfram.com/xid/0b7ekgesiu28r68m-bud71n

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

https://wolfram.com/xid/0b7ekgesiu28r68m-nnksx4


https://wolfram.com/xid/0b7ekgesiu28r68m-exhx0q
The order of the datasets affects the test results:

https://wolfram.com/xid/0b7ekgesiu28r68m-f3e5kf


https://wolfram.com/xid/0b7ekgesiu28r68m-jqamzo

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

https://wolfram.com/xid/0b7ekgesiu28r68m-cbbn53

https://wolfram.com/xid/0b7ekgesiu28r68m-fnaxqn

https://wolfram.com/xid/0b7ekgesiu28r68m-f9ns4d

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

https://wolfram.com/xid/0b7ekgesiu28r68m-hkcfuq

Create a HypothesisTestData object for repeated property extraction:

https://wolfram.com/xid/0b7ekgesiu28r68m-0x5m5

https://wolfram.com/xid/0b7ekgesiu28r68m-cc8eh1
The properties available for extraction:

https://wolfram.com/xid/0b7ekgesiu28r68m-frvg20

Extract some properties from a HypothesisTestData object:

https://wolfram.com/xid/0b7ekgesiu28r68m-c03go

https://wolfram.com/xid/0b7ekgesiu28r68m-bpn9dr
The -value and test statistic:

https://wolfram.com/xid/0b7ekgesiu28r68m-365dq


https://wolfram.com/xid/0b7ekgesiu28r68m-bn5rjv

Extract any number of properties simultaneously:

https://wolfram.com/xid/0b7ekgesiu28r68m-bycagv

https://wolfram.com/xid/0b7ekgesiu28r68m-dmu6hk
The -value and test statistic from a Mann–Whitney test:

https://wolfram.com/xid/0b7ekgesiu28r68m-i6fwj7

Reporting (3)

https://wolfram.com/xid/0b7ekgesiu28r68m-ba6zb1

https://wolfram.com/xid/0b7ekgesiu28r68m-hb1mu5

https://wolfram.com/xid/0b7ekgesiu28r68m-hh3kq

Retrieve the entries from a test table for customized reporting:

https://wolfram.com/xid/0b7ekgesiu28r68m-cg07e5

https://wolfram.com/xid/0b7ekgesiu28r68m-98x7a

https://wolfram.com/xid/0b7ekgesiu28r68m-fforak

Tabulate -values or test statistics:

https://wolfram.com/xid/0b7ekgesiu28r68m-fr3ezf

https://wolfram.com/xid/0b7ekgesiu28r68m-blo8x

https://wolfram.com/xid/0b7ekgesiu28r68m-g8i1dt


https://wolfram.com/xid/0b7ekgesiu28r68m-o0wuj


https://wolfram.com/xid/0b7ekgesiu28r68m-dw7vzl

The test statistic from the table:

https://wolfram.com/xid/0b7ekgesiu28r68m-bitsqd

Generalizations & Extensions (2)Generalized and extended use cases
The Mann–Whitney test ignores the time stamps when the input is a TimeSeries:

https://wolfram.com/xid/0b7ekgesiu28r68m-7py5sj

https://wolfram.com/xid/0b7ekgesiu28r68m-0467fg

https://wolfram.com/xid/0b7ekgesiu28r68m-57bf57


https://wolfram.com/xid/0b7ekgesiu28r68m-vvd88

The Mann–Whitney test recognizes the path structure of a TemporalData with exactly two paths:

https://wolfram.com/xid/0b7ekgesiu28r68m-qry3ls

https://wolfram.com/xid/0b7ekgesiu28r68m-b1l4g0


https://wolfram.com/xid/0b7ekgesiu28r68m-jdvl55

Options (12)Common values & functionality for each option
AlternativeHypothesis (4)
A two-sided test is performed by default:

https://wolfram.com/xid/0b7ekgesiu28r68m-bgoxnx

https://wolfram.com/xid/0b7ekgesiu28r68m-he0w0s


https://wolfram.com/xid/0b7ekgesiu28r68m-jqt2u8

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

https://wolfram.com/xid/0b7ekgesiu28r68m-kwmm8d

https://wolfram.com/xid/0b7ekgesiu28r68m-dy0fuc


https://wolfram.com/xid/0b7ekgesiu28r68m-g8h639


https://wolfram.com/xid/0b7ekgesiu28r68m-f19ykz

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

https://wolfram.com/xid/0b7ekgesiu28r68m-cay5xk

https://wolfram.com/xid/0b7ekgesiu28r68m-v01gr


https://wolfram.com/xid/0b7ekgesiu28r68m-ci67wa


https://wolfram.com/xid/0b7ekgesiu28r68m-m3sbc

The two-sided test is symmetric under the exchange of the datasets:

https://wolfram.com/xid/0b7ekgesiu28r68m-e2hwfp

https://wolfram.com/xid/0b7ekgesiu28r68m-k0o4ez

The one-sided tests are not symmetric under the exchange of the datasets:

https://wolfram.com/xid/0b7ekgesiu28r68m-n8xq3


https://wolfram.com/xid/0b7ekgesiu28r68m-p54su9

However, for the permutation method even the (default) two-sided test is not symmetric:

https://wolfram.com/xid/0b7ekgesiu28r68m-gezxwu

MaxIterations (2)
Set the maximum number of iterations to use for multivariate tests:

https://wolfram.com/xid/0b7ekgesiu28r68m-wsdxy
By default, 250 iterations are allowed:

https://wolfram.com/xid/0b7ekgesiu28r68m-l6esri


https://wolfram.com/xid/0b7ekgesiu28r68m-eb62z0

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

https://wolfram.com/xid/0b7ekgesiu28r68m-z0x96
The -values are not equivalent:

https://wolfram.com/xid/0b7ekgesiu28r68m-hu3jt7



https://wolfram.com/xid/0b7ekgesiu28r68m-xar3i

Method (5)
For small samples, -values are computed using an exact formula by default:

https://wolfram.com/xid/0b7ekgesiu28r68m-n5553

https://wolfram.com/xid/0b7ekgesiu28r68m-798j7


https://wolfram.com/xid/0b7ekgesiu28r68m-d8n542

For large samples, -values are computed using asymptotic test statistic distributions by default:

https://wolfram.com/xid/0b7ekgesiu28r68m-v21sy

https://wolfram.com/xid/0b7ekgesiu28r68m-fifdab


https://wolfram.com/xid/0b7ekgesiu28r68m-b9g9ag

Permutation methods can be used:

https://wolfram.com/xid/0b7ekgesiu28r68m-hy6ohx

https://wolfram.com/xid/0b7ekgesiu28r68m-f69ts


https://wolfram.com/xid/0b7ekgesiu28r68m-drrw70

Set the number of permutations to use:

https://wolfram.com/xid/0b7ekgesiu28r68m-cv172p

https://wolfram.com/xid/0b7ekgesiu28r68m-co5msl


https://wolfram.com/xid/0b7ekgesiu28r68m-dicab0

By default, random permutations are used:

https://wolfram.com/xid/0b7ekgesiu28r68m-ktxmmb

Set the seed used for generating random permutations:

https://wolfram.com/xid/0b7ekgesiu28r68m-cjrea

https://wolfram.com/xid/0b7ekgesiu28r68m-0du0


https://wolfram.com/xid/0b7ekgesiu28r68m-f7dru0

SignificanceLevel (1)
The significance level is used for "TestConclusion" and "ShortTestConclusion":

https://wolfram.com/xid/0b7ekgesiu28r68m-bhkod7

https://wolfram.com/xid/0b7ekgesiu28r68m-lasldz

https://wolfram.com/xid/0b7ekgesiu28r68m-hykroc

https://wolfram.com/xid/0b7ekgesiu28r68m-bvt7nt


https://wolfram.com/xid/0b7ekgesiu28r68m-hpqqgh


https://wolfram.com/xid/0b7ekgesiu28r68m-flavjg


https://wolfram.com/xid/0b7ekgesiu28r68m-m2oyg2

Applications (3)Sample problems that can be solved with this function
Test whether the medians of some populations are equal:

https://wolfram.com/xid/0b7ekgesiu28r68m-4kn67

https://wolfram.com/xid/0b7ekgesiu28r68m-elrcz

The medians of the first two populations are similar:

https://wolfram.com/xid/0b7ekgesiu28r68m-iwddm4

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

https://wolfram.com/xid/0b7ekgesiu28r68m-bwrr6i

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

https://wolfram.com/xid/0b7ekgesiu28r68m-f5fyyr

https://wolfram.com/xid/0b7ekgesiu28r68m-doox3i

https://wolfram.com/xid/0b7ekgesiu28r68m-sv0lc

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

https://wolfram.com/xid/0b7ekgesiu28r68m-po4rt

https://wolfram.com/xid/0b7ekgesiu28r68m-50pb8

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

https://wolfram.com/xid/0b7ekgesiu28r68m-izhcxv

https://wolfram.com/xid/0b7ekgesiu28r68m-tfoq2


https://wolfram.com/xid/0b7ekgesiu28r68m-cwtxjk
Determine if there is a difference in the first four morphological measures for the two varieties:

https://wolfram.com/xid/0b7ekgesiu28r68m-b3cj4o


https://wolfram.com/xid/0b7ekgesiu28r68m-hfs4ix

Compare the morphological measures across the genders:

https://wolfram.com/xid/0b7ekgesiu28r68m-gxu7d3


https://wolfram.com/xid/0b7ekgesiu28r68m-nuygkj

Properties & Relations (4)Properties of the function, and connections to other functions
For univariate data, the test statistic follows a NormalDistribution[0,1] under :

https://wolfram.com/xid/0b7ekgesiu28r68m-b9u4tx

https://wolfram.com/xid/0b7ekgesiu28r68m-mn9zg

https://wolfram.com/xid/0b7ekgesiu28r68m-be6r5c
A large sample approximation to the NormalDistribution:

https://wolfram.com/xid/0b7ekgesiu28r68m-i6xczx

https://wolfram.com/xid/0b7ekgesiu28r68m-evb0jl

https://wolfram.com/xid/0b7ekgesiu28r68m-dwvfqv


https://wolfram.com/xid/0b7ekgesiu28r68m-eb3599

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

https://wolfram.com/xid/0b7ekgesiu28r68m-fcw44i

https://wolfram.com/xid/0b7ekgesiu28r68m-mktqe4

https://wolfram.com/xid/0b7ekgesiu28r68m-kx8eo0

https://wolfram.com/xid/0b7ekgesiu28r68m-2v5dw


https://wolfram.com/xid/0b7ekgesiu28r68m-bfkrj9


https://wolfram.com/xid/0b7ekgesiu28r68m-pdfbx5

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

https://wolfram.com/xid/0b7ekgesiu28r68m-czw9ty

https://wolfram.com/xid/0b7ekgesiu28r68m-liumv
In the absence of ties, Ordering can compute the ranks:

https://wolfram.com/xid/0b7ekgesiu28r68m-z1gqk

https://wolfram.com/xid/0b7ekgesiu28r68m-easm4


https://wolfram.com/xid/0b7ekgesiu28r68m-gbsp9h

The exact -value matches the frequencies of the test statistic when considering every possible permutation for a given size of the datasets:

https://wolfram.com/xid/0b7ekgesiu28r68m-cjs4w1

https://wolfram.com/xid/0b7ekgesiu28r68m-p701ns


https://wolfram.com/xid/0b7ekgesiu28r68m-gd3kz7

Compute the statistics and -values for all the permutation pairs:

https://wolfram.com/xid/0b7ekgesiu28r68m-eerfer

https://wolfram.com/xid/0b7ekgesiu28r68m-c7w8lu

Compute frequencies by normalizing the counts of the statistic:

https://wolfram.com/xid/0b7ekgesiu28r68m-jhfe4u
The statistic is an integer between and the product of the lengths of the data inputs—here
:

https://wolfram.com/xid/0b7ekgesiu28r68m-eh8wbb

Since the -value is the cumulative mass function (CDF) of the test distribution, it needs to be compared to the cumulative frequencies:

https://wolfram.com/xid/0b7ekgesiu28r68m-dv312t

By convention, the -values start at
:

https://wolfram.com/xid/0b7ekgesiu28r68m-3wkst

The exact -value is computed using the following recursion relation:

https://wolfram.com/xid/0b7ekgesiu28r68m-1g2hk

https://wolfram.com/xid/0b7ekgesiu28r68m-h1yxsm

https://wolfram.com/xid/0b7ekgesiu28r68m-p7ie3

Possible Issues (1)Common pitfalls and unexpected behavior
Neat Examples (1)Surprising or curious use cases
Compute the statistic when the null hypothesis is true:

https://wolfram.com/xid/0b7ekgesiu28r68m-2qqg3c

https://wolfram.com/xid/0b7ekgesiu28r68m-ywy3ty
The test statistic given a particular alternative:

https://wolfram.com/xid/0b7ekgesiu28r68m-612aqt

https://wolfram.com/xid/0b7ekgesiu28r68m-c5cy2n
Compare the distributions of the test statistics:

https://wolfram.com/xid/0b7ekgesiu28r68m-87eb6q

Wolfram Research (2010), MannWhitneyTest, Wolfram Language function, https://reference.wolfram.com/language/ref/MannWhitneyTest.html.
Text
Wolfram Research (2010), MannWhitneyTest, Wolfram Language function, https://reference.wolfram.com/language/ref/MannWhitneyTest.html.
Wolfram Research (2010), MannWhitneyTest, Wolfram Language function, https://reference.wolfram.com/language/ref/MannWhitneyTest.html.
CMS
Wolfram Language. 2010. "MannWhitneyTest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MannWhitneyTest.html.
Wolfram Language. 2010. "MannWhitneyTest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MannWhitneyTest.html.
APA
Wolfram Language. (2010). MannWhitneyTest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MannWhitneyTest.html
Wolfram Language. (2010). MannWhitneyTest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MannWhitneyTest.html
BibTeX
@misc{reference.wolfram_2025_mannwhitneytest, author="Wolfram Research", title="{MannWhitneyTest}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/MannWhitneyTest.html}", note=[Accessed: 29-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_mannwhitneytest, organization={Wolfram Research}, title={MannWhitneyTest}, year={2010}, url={https://reference.wolfram.com/language/ref/MannWhitneyTest.html}, note=[Accessed: 29-March-2025
]}