Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • System Modeler

    Multidomain modeling and simulation of complex systems

  • Compute ServicesUse with Mathematica and Wolfram|One
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Wolfram|Alpha

  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs

AI Products

  • Wolfram AI Ecosystem
  • Wolfram Foundation Tool
  • Wolfram Cloud MCP
  • Wolfram Local MCP
  • Agent One API
  • CAG Component APIs

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • Linguistic Understanding

Additional Deployment Options

  • Wolfram Cloud
  • Wolfram Web Engine
  • wolframscript
  • WSTPServer
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

Wolfram Consulting

Data Science, Finance & Business

  • Artificial Intelligence
  • Data Science
  • Healthcare
  • Real Estate

Engineering

  • Civil Engineering
  • Automotive Engineering
  • Sustainable Energy

Science & Technology

  • AgTech
  • Biosciences
  • Environmental Science
  • Food Science
  • Quantum Computation
  • Social and Behavioral Sciences

More Wolfram Solutions

Technology for Education

  • Research Universities
  • Colleges & Teaching Universities
  • High Schools
  • Resources for Students

Education Initiatives

  • Next-Gen EdTech
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
For AIs
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • System Modeler
    • Compute ServicesUse with Mathematica and Wolfram|One
    • AI AccessUse with Mathematica and Wolfram|One
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Wolfram|Alpha
      • Wolfram|Alpha Website
      • Wolfram|Alpha APIs
    • AI Products
      • Wolfram AI Ecosystem
      • Wolfram Foundation Tool
      • Wolfram Cloud MCP
      • Wolfram Local MCP
      • Agent One API
      • CAG Component APIs
    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • Linguistic Understanding
    • Additional Deployment Options
      • Wolfram Cloud
      • Wolfram Web Engine
      • wolframscript
      • WSTPServer
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions
    • Wolfram Consulting

    Data Science, Finance & Business

    • Artificial Intelligence
    • Data Science
    • Healthcare
    • Real Estate

    Engineering

    • Civil Engineering
    • Automotive Engineering
    • Sustainable Energy

    Science & Technology

    • AgTech
    • Biosciences
    • Environmental Science
    • Food Science
    • Quantum Computation
    • Social and Behavioral Sciences

    More Wolfram Solutions

    Technology for Education

    • Research Universities
    • Colleges & Teaching Universities
    • High Schools
    • Resources for Students

    Education Initiatives

    • Next-Gen EdTech
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • For AIs
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
MannWhitneyTest
  • See Also
    • HypothesisTestData
    • LocationTest
    • LocationEquivalenceTest
    • VarianceTest
    • VarianceEquivalenceTest
    • DistributionFitTest
    • PairedTTest
    • PairedZTest
    • SignTest
    • SignedRankTest
    • TTest
    • ZTest
  • Related Guides
    • Hypothesis Tests
    • Random Variables
    • See Also
      • HypothesisTestData
      • LocationTest
      • LocationEquivalenceTest
      • VarianceTest
      • VarianceEquivalenceTest
      • DistributionFitTest
      • PairedTTest
      • PairedZTest
      • SignTest
      • SignedRankTest
      • TTest
      • ZTest
    • Related Guides
      • Hypothesis Tests
      • Random Variables

MannWhitneyTest[{data1,data2}]

tests whether the medians of data1 and data2 are equal.

MannWhitneyTest[dspec,μ0]

tests the median difference against μ0.

MannWhitneyTest[dspec,μ0,"property"]

returns the value of "property".

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Testing  
Reporting  
Generalizations & Extensions  
Options  
AlternativeHypothesis  
MaxIterations  
Method  
SignificanceLevel  
Applications  
Properties & Relations  
Possible Issues  
Neat Examples  
See Also
Related Guides
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • HypothesisTestData
    • LocationTest
    • LocationEquivalenceTest
    • VarianceTest
    • VarianceEquivalenceTest
    • DistributionFitTest
    • PairedTTest
    • PairedZTest
    • SignTest
    • SignedRankTest
    • TTest
    • ZTest
  • Related Guides
    • Hypothesis Tests
    • Random Variables
    • See Also
      • HypothesisTestData
      • LocationTest
      • LocationEquivalenceTest
      • VarianceTest
      • VarianceEquivalenceTest
      • DistributionFitTest
      • PairedTTest
      • PairedZTest
      • SignTest
      • SignedRankTest
      • TTest
      • ZTest
    • Related Guides
      • Hypothesis Tests
      • Random Variables

MannWhitneyTest

MannWhitneyTest[{data1,data2}]

tests whether the medians of data1 and data2 are equal.

MannWhitneyTest[dspec,μ0]

tests the median difference against μ0.

MannWhitneyTest[dspec,μ0,"property"]

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
  • 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 univariate samples, MannWhitneyTest performs the Mann–Whitney -test for median differences of independent samples. The following methods are available:
  • Automaticchooses 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 all close all

Basic Examples  (2)

Test whether the medians of two independent populations differ:

Wolfram Language code: BlockRandom[SeedRandom[2];data1 = RandomVariate[NormalDistribution[.1, 1], 1000]; data2 = RandomVariate[NormalDistribution[0, 1], 1000]];

The median difference :

Wolfram Language code: Median[data1] - Median[data2]
Wolfram Language code: SmoothHistogram[{data1, data2}]

At the 0.05 level, the medians are significantly different:

Wolfram Language code: MannWhitneyTest[{data1, data2}]

Compare the locations of multivariate populations:

Wolfram Language code: BlockRandom[SeedRandom[2];data1 = RandomVariate[MultinormalDistribution[{1, 2}, IdentityMatrix[2]], 30]; data2 = RandomVariate[MultinormalDistribution[{0, 0}, IdentityMatrix[2]], 50];]

The median difference vector :

Wolfram Language code: Median[data1] - Median[data2]
Wolfram Language code: Histogram3D[{data1, Transpose[Transpose[data2] + {1, 2}]}]

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

Wolfram Language code: MannWhitneyTest[{data1, data2}, {1, 2}]

Scope  (9)

Testing  (6)

Test versus :

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 100]; data2 = RandomVariate[NormalDistribution[1, 1], 100]; data3 = RandomVariate[NormalDistribution[0, 2], 100];

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

Wolfram Language code: MannWhitneyTest[{data1, data2}]

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

Wolfram Language code: MannWhitneyTest[{data1, data3}]

Test versus :

Wolfram Language code: data1 = RandomVariate[NormalDistribution[3, 1], 100]; data2 = RandomVariate[NormalDistribution[0, 1], 100];

The order of the datasets affects the test results:

Wolfram Language code: MannWhitneyTest[{data1, data2}, 3]
Wolfram Language code: MannWhitneyTest[{data2, data1}, 3]

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

Wolfram Language code: data1 = RandomVariate[MultinormalDistribution[{.5, 0, -.5, 0}, IdentityMatrix[4]], 75];
Wolfram Language code: data2 = RandomVariate[MultinormalDistribution[{-.5, 0, .5, 0}, IdentityMatrix[4]], 63];
Wolfram Language code: MannWhitneyTest[{data1, data2}]

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

Wolfram Language code: MannWhitneyTest[{data1, data2}, {1, 0, -1, 0}]

Create a HypothesisTestData object for repeated property extraction:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 10^4}];
Wolfram Language code: ℋ = MannWhitneyTest[data, 0, "HypothesisTestData"];

The properties available for extraction:

Wolfram Language code: ℋ["Properties"]

Extract some properties from a HypothesisTestData object:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 10^4}];
Wolfram Language code: ℋ = MannWhitneyTest[data, 0, "HypothesisTestData"];

The -value and test statistic:

Wolfram Language code: ℋ["PValue"]
Wolfram Language code: ℋ["TestStatistic"]

Extract any number of properties simultaneously:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 10^4}];
Wolfram Language code: ℋ = MannWhitneyTest[data, 0, "HypothesisTestData"];

The -value and test statistic from a Mann–Whitney test:

Wolfram Language code: ℋ["PValue", "TestStatistic"]

Reporting  (3)

Tabulate the test results:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 20}];
Wolfram Language code: ℋ = MannWhitneyTest[data, 0, "HypothesisTestData"];
Wolfram Language code: ℋ["TestDataTable"]

Retrieve the entries from a test table for customized reporting:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[], {1000, 25}]; data2 = RandomVariate[NormalDistribution[], {1000, 30}];
Wolfram Language code: res = MapThread[MannWhitneyTest[{#1, #2}, 0, "TestData"]&, {data1, data2}];
Wolfram Language code: ListPlot[res, FrameLabel -> {"U", "p-value"}, Frame -> True, PlotRange -> All]

Tabulate -values or test statistics:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 10^2}];
Wolfram Language code: ℋ = MannWhitneyTest[data, 0, "HypothesisTestData"];
Wolfram Language code: ℋ["PValueTable"]

The -value from the table:

Wolfram Language code: ℋ["PValue"]
Wolfram Language code: ℋ["TestStatisticTable"]

The test statistic from the table:

Wolfram Language code: ℋ["TestStatistic"]

Generalizations & Extensions  (2)

The Mann–Whitney test ignores the time stamps when the input is a TimeSeries:

Wolfram Language code: ts1 = TemporalData[TimeSeries, {{{1.224578634529677, 0.47929635789978015, 0.6572781300178168, 0.21496048742669355, 0.7299608014554928, -0.2495111111278263, -1.3286551762002712, 0.552725018274874, 0.19272112205837066, 1.1809144012420882, -1.1671 ... 40938613662046, 1.052394590214582, 0.9345044123980388, 0.38537803109557855, -0.48660931166089394, -0.71203560340161}}, {{0, 100, 1}}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, {ValueDimensions -> 1, ResamplingMethod -> None}}, False, 10.1];
Wolfram Language code: ts2 = TemporalData[TimeSeries, {{{-1.2160757838495546, 0.5212591188357838, -0.0932747538180776, -2.306367634798702, -2.5366722726947994, -0.7924813212437647, -2.65435901675047, -1.1098678592653723, -0.7814091835518528, -1.9685555851254093, -0.0 ... 1001061264, -0.1887471329804458, -2.0547107874294928, -1.3896240275653011, -0.5073077090484948, 0.13302942350391606}}, {{0, 100, 1}}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, {ValueDimensions -> 1, ResamplingMethod -> None}}, False, 10.1];
Wolfram Language code: MannWhitneyTest[{ts1, ts2}]
Wolfram Language code: MannWhitneyTest[{ts1["Values"], ts2["Values"]}]

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

Wolfram Language code: td = TemporalData[Automatic, {{{1.224578634529677, 0.47929635789978015, 0.6572781300178168, 0.21496048742669355, 0.7299608014554928, -0.2495111111278263, -1.3286551762002712, 0.552725018274874, 0.19272112205837066, 1.1809144012420882, -1.16711 ... 01061264, -0.1887471329804458, -2.0547107874294928, -1.3896240275653011, -0.5073077090484948, 0.13302942350391606}}, {{0, 100, 1}}, 2, {"Continuous", 2}, {"Discrete", 1}, 1, {ValueDimensions -> 1, ResamplingMethod -> None}}, False, 10.1];
Wolfram Language code: MannWhitneyTest[td]

Use the values directly:

Wolfram Language code: MannWhitneyTest[td["ValueList"]]

Options  (12)

AlternativeHypothesis  (4)

A two-sided test is performed by default:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 100}];

Test versus :

Wolfram Language code: MannWhitneyTest[data, 0, AlternativeHypothesis -> "Unequal"]
Wolfram Language code: MannWhitneyTest[data, 0, AlternativeHypothesis -> Automatic]

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

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 100}];

Test versus :

Wolfram Language code: MannWhitneyTest[data, 0, AlternativeHypothesis -> "Unequal"]

Test versus :

Wolfram Language code: MannWhitneyTest[data, 0, AlternativeHypothesis -> "Less"]

Test versus :

Wolfram Language code: MannWhitneyTest[data, 0, AlternativeHypothesis -> "Greater"]

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

Wolfram Language code: data1 = RandomVariate[NormalDistribution[2.9, 1], 1000]; data2 = RandomVariate[NormalDistribution[0, 1], 1000];
Wolfram Language code: Mean[data1] - Mean[data2]

Test versus :

Wolfram Language code: MannWhitneyTest[{data1, data2}, 3, AlternativeHypothesis -> "Less"]

Test versus :

Wolfram Language code: MannWhitneyTest[{data1, data2}, 2.9, AlternativeHypothesis -> "Less"]

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

Wolfram Language code: {data1, data2} = RandomVariate[NormalDistribution[], {2, 100}];
Wolfram Language code: MannWhitneyTest[{data1, data2}, AlternativeHypothesis -> "Unequal"] == MannWhitneyTest[{data2, data1}, AlternativeHypothesis -> "Unequal"]

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

Wolfram Language code: MannWhitneyTest[{data1, data2}, AlternativeHypothesis -> "Less"] == MannWhitneyTest[{data2, data1}, AlternativeHypothesis -> "Less"]
Wolfram Language code: MannWhitneyTest[{data1, data2}, AlternativeHypothesis -> "Greater"] == MannWhitneyTest[{data2, data1}, AlternativeHypothesis -> "Greater"]

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

Wolfram Language code: MannWhitneyTest[{data1, data2}, Method -> "Permutation"] == MannWhitneyTest[{data2, data1}, Method -> "Permutation"]

MaxIterations  (2)

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

Wolfram Language code: data1 = RandomVariate[BinormalDistribution[.5], 25]; data2 = RandomVariate[BinormalDistribution[.5], 25];

By default, 250 iterations are allowed:

Wolfram Language code: MannWhitneyTest[{data1, data2}, Automatic, MaxIterations -> 250]
Wolfram Language code: MannWhitneyTest[{data1, data2}, Automatic, MaxIterations -> Automatic]

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

Wolfram Language code: BlockRandom[SeedRandom[2]; data1 = RandomVariate[BinormalDistribution[.5], 25]; data2 = RandomVariate[BinormalDistribution[.5], 25];]

The -values are not equivalent:

Wolfram Language code: MannWhitneyTest[{data1, data2}, Automatic, MaxIterations -> 1]
Wolfram Language code: MannWhitneyTest[{data1, data2}, Automatic, MaxIterations -> Automatic]

Method  (5)

For small samples, -values are computed using an exact formula by default:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 20}];
Wolfram Language code: MannWhitneyTest[data, 0, Method -> Automatic]
Wolfram Language code: MannWhitneyTest[data, 0, Method -> "Exact"]

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

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 100}];
Wolfram Language code: MannWhitneyTest[data, 0, Method -> Automatic]
Wolfram Language code: MannWhitneyTest[data, 0, Method -> "Asymptotic"]

Permutation methods can be used:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 35}];
Wolfram Language code: MannWhitneyTest[data, 0, Method -> "Asymptotic"]
Wolfram Language code: MannWhitneyTest[data, 0, Method -> "Permutation"]

Set the number of permutations to use:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 35}];
Wolfram Language code: MannWhitneyTest[data, 0, Method -> {"Permutation", "MonteCarloSamples" -> 10^3}]
Wolfram Language code: MannWhitneyTest[data, 0, Method -> {"Permutation", "MonteCarloSamples" -> 10^5}]

By default, random permutations are used:

Wolfram Language code: MannWhitneyTest[data, 0, Method -> {"Permutation", "MonteCarloSamples" -> 10^4}]

Set the seed used for generating random permutations:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {2, 35}];
Wolfram Language code: MannWhitneyTest[data, 0, Method -> {"Permutation", "RandomSeed" -> 0}]
Wolfram Language code: MannWhitneyTest[data, 0, Method -> {"Permutation", "RandomSeed" -> 9}]

SignificanceLevel  (1)

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

Wolfram Language code: data = BlockRandom[SeedRandom[1];RandomVariate[NormalDistribution[0, 1], {2, 100}]];
Wolfram Language code: ℋ1 = MannWhitneyTest[data, .395, "HypothesisTestData", SignificanceLevel -> .05];
Wolfram Language code: ℋ2 = MannWhitneyTest[data, .395, "HypothesisTestData", SignificanceLevel -> .00001];
Wolfram Language code: ℋ1["TestConclusion"]//TraditionalForm
Wolfram Language code: ℋ2["TestConclusion"]//TraditionalForm
Wolfram Language code: ℋ1["ShortTestConclusion"]
Wolfram Language code: ℋ2["ShortTestConclusion"]

Applications  (3)

Test whether the medians of some populations are equal:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], 100]; data2 = RandomVariate[NormalDistribution[0, 1], 120]; data3 = RandomVariate[NormalDistribution[2, 1], 135];
Wolfram Language code: BoxWhiskerChart[{data1, data2, data3}]

The medians of the first two populations are similar:

Wolfram Language code: MannWhitneyTest[{data1, data2}, Automatic, "TestDataTable"]

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

Wolfram Language code: MannWhitneyTest[{data1, data3}, Automatic, "TestDataTable"]

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

Wolfram Language code: oldF = ExampleData[{"Statistics", "OldFaithful"}];
Wolfram Language code: Subscript[𝒟, OldF] = SmoothKernelDistribution[oldF];
Wolfram Language code: DensityPlot[Evaluate@PDF[Subscript[𝒟, OldF], {x, y}], {x, 1, 5.5}, {y, 35, 100}, PlotRange -> All, ColorFunction -> "DeepSeaColors", PlotPoints -> 100]

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

Wolfram Language code: longWait = Cases[oldF, {x_, y_} /; y > 60][[All, 1]]; shortWait = Cases[oldF, {x_, y_} /; y <= 60][[All, 1]];
Wolfram Language code: MannWhitneyTest[{longWait, shortWait}, 0, "TestDataTable", AlternativeHypothesis -> "Greater"]

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

Wolfram Language code: data = ExampleData[{"Statistics", "CrabMeasures"}];
Wolfram Language code: ExampleData[{"Statistics", "CrabMeasures"}, "ColumnDescriptions"]
Wolfram Language code: crabData = data[[All, 4 ;; -2]]; species = data[[All, 1]]; gender = data[[All, 2]];

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

Wolfram Language code: Table[SmoothHistogram[{Pick[crabData, species, "B"][[All, i]], Pick[crabData, species, "O"][[All, i]]}, PlotLabel -> ExampleData[{"Statistics", "CrabMeasures"}, "ColumnHeadings"][[i + 3]], Ticks -> None], {i, 4}]
Wolfram Language code: MannWhitneyTest[{Pick[crabData, species, "B"], Pick[crabData, species, "O"]}, Automatic, "TestDataTable"]

Compare the morphological measures across the genders:

Wolfram Language code: Table[SmoothHistogram[{Pick[crabData, gender, "F"][[All, i]], Pick[crabData, gender, "M"][[All, i]]}, PlotLabel -> ExampleData[{"Statistics", "CrabMeasures"}, "ColumnHeadings"][[i + 3]], Ticks -> None], {i, 4}]
Wolfram Language code: MannWhitneyTest[{Pick[crabData, gender, "M"], Pick[crabData, gender, "F"]}, Automatic, "TestDataTable"]

Properties & Relations  (4)

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

Wolfram Language code: n = 250;m = 200;
Wolfram Language code: data1 = RandomVariate[NormalDistribution[], {1000, n}]; data2 = RandomVariate[NormalDistribution[], {1000, m}];
Wolfram Language code: t = MapThread[MannWhitneyTest[{#1, #2}, Automatic, "TestStatistic"]&, {data1, data2}];

A large sample approximation to the NormalDistribution:

Wolfram Language code: correction[T_] := ((T - (n m/2)/Sqrt[(n m (n + m + 1)/12)]))
Wolfram Language code: tcor = N@Table[correction[i], {i, t}];
Wolfram Language code: Show[Plot[PDF[NormalDistribution[], x], {x, -4, 4}], SmoothHistogram[tcor, PlotStyle -> Orange]]
Wolfram Language code: DistributionFitTest[tcor]

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

Wolfram Language code: data1 = RandomVariate[BinormalDistribution[.5], {250, 15}]; data2 = RandomVariate[BinormalDistribution[.5], {250, 15}];
Wolfram Language code: dim = 2;
Wolfram Language code: t = MapThread[MannWhitneyTest[{#1, #2}, Automatic, "TestStatistic"]&, {data1, data2}];
Wolfram Language code: Show[Histogram[t, Automatic, "PDF"], Plot[PDF[ChiSquareDistribution[dim], x], {x, 0, 9}, PlotStyle -> Thick]]
Wolfram Language code: DistributionFitTest[t, ChiSquareDistribution[dim]]
Wolfram Language code: DistributionFitTest[t, ChiSquareDistribution[dim], "ShortTestConclusion"]

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

Wolfram Language code: n = 100;m = 120;
Wolfram Language code: data1 = RandomVariate[NormalDistribution[], n]; data2 = RandomVariate[NormalDistribution[], m];

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

Wolfram Language code: ranks2 = Ordering[Ordering[Join[data1, data2]]][[n + 1 ;; -1]];
Wolfram Language code: n * m + ((m(m + 1)) / 2) - Total[ranks2]
Wolfram Language code: MannWhitneyTest[{data1, data2}, Automatic, "TestStatistic"]

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

Wolfram Language code: permutations = (Partition[#, 4]& /@ Permutations[Range[8]]);
Wolfram Language code: Dimensions[permutations]

Show few permutations:

Wolfram Language code: RandomSample[permutations, 4]

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

Wolfram Language code: TPs = Table[ MannWhitneyTest[dat, 0, {"TestStatistic", "PValue"}, Method -> "Exact", AlternativeHypothesis -> "Less"] , {dat, permutations} ];

Show few results:

Wolfram Language code: RandomSample[TPs, 5]//Rationalize

Compute frequencies by normalizing the counts of the statistic:

Wolfram Language code: counts = Counts[Rationalize@TPs] / Length[TPs];

The statistic is an integer between and the product of the lengths of the data inputs—here :

Wolfram Language code: {Ts, Ps} = Transpose[Keys[counts]]

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

Wolfram Language code: cumulativeFrequencies = Accumulate[Values[counts]]

By convention, the -values start at :

Wolfram Language code: Rest[Ps] == Most[cumulativeFrequencies]

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

Wolfram Language code: A[U_ ? Negative, __] := 0; A[_, _, 0] = 1; A[_, 0, _] = 1; A[U_, n1_, m1_] := A[U, n1 - 1, m1] + A[U - n1, n1, m1 - 1];
Wolfram Language code: PLess[U_, n1_, m1_] := A[U - 1, n1, m1] / Binomial[n1 + m1, m1];
Wolfram Language code: With[{n = RandomInteger[{1, Length[Ps]}]}, PLess[Ts[[n]], 4, 4] == Ps[[n]] ]

Possible Issues  (1)

For the permutation method, the two-sided test is not symmetric under the exchange of the datasets:

Wolfram Language code: {data1, data2} = RandomVariate[NormalDistribution[], {2, 100}];
Wolfram Language code: MannWhitneyTest[{data1, data2}, Method -> "Permutation"] == MannWhitneyTest[{data2, data1}, Method -> "Permutation"]

Neat Examples  (1)

Compute the statistic when the null hypothesis is true:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[0, 1], {250, 100}]; data2 = RandomVariate[NormalDistribution[0, 2], {250, 100}];
Wolfram Language code: T1 = MapThread[MannWhitneyTest[{#1, #2}, 0, "TestStatistic"]&, {data1, data2}];

The test statistic given a particular alternative:

Wolfram Language code: data3 = RandomVariate[NormalDistribution[2, 1], {250, 100}];
Wolfram Language code: T2 = MapThread[MannWhitneyTest[{#1, #2}, 0, "TestStatistic"]&, {data1, data3}];

Compare the distributions of the test statistics:

Wolfram Language code: SmoothHistogram[{T1, T2}, Filling -> Axis, PlotLegends -> {"SubscriptBox[H, 0] is True", "SubscriptBox[H, 0] is False"}]

See Also

HypothesisTestData  LocationTest  LocationEquivalenceTest  VarianceTest  VarianceEquivalenceTest  DistributionFitTest  PairedTTest  PairedZTest  SignTest  SignedRankTest  TTest  ZTest

Related Guides

    ▪
  • Hypothesis Tests
  • ▪
  • Random Variables

History

Introduced in 2010 (8.0)

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.

CMS

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

BibTeX

@misc{reference.wolfram_2026_mannwhitneytest, author="Wolfram Research", title="{MannWhitneyTest}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/MannWhitneyTest.html}", note=[Accessed: 01-September-2026]}

BibLaTeX

@online{reference.wolfram_2026_mannwhitneytest, organization={Wolfram Research}, title={MannWhitneyTest}, year={2010}, url={https://reference.wolfram.com/language/ref/MannWhitneyTest.html}, note=[Accessed: 01-September-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • AI Access
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English