Skip to main content
返回指南
4 min read6 步骤

How to Calculate the Mann-Whitney U Test: Step-by-Step Guide

Learn to manually calculate the Mann-Whitney U test for non-parametric group comparisons. Understand the formula, work through an example, and avoid common errors.

跳过数学——使用计算器

分步说明

1

State Hypotheses and Set Significance Level

First, clearly define your null (H₀) and alternative (H₁) hypotheses. For the Mann-Whitney U test, H₀ typically states that there is no difference in the distributions (or medians) between the two independent groups. H₁ states that there is a difference. Also, determine your significance level (α), commonly 0.05, which is the threshold for statistical significance.

2

Combine and Rank All Data

Combine all observations from both groups into a single dataset. Then, rank all combined observations from smallest (rank 1) to largest (rank N, where N = n₁ + n₂). If there are ties (two or more observations have the same value), assign each tied observation the average of the ranks they would have received. For example, if two values are tied for the 3rd and 4th ranks, both receive a rank of (3+4)/2 = 3.5. **Example Data and Ranks:** | Score | Group | Initial Rank | Adjusted Rank (for ties) | | ----- | ------- | ------------ | ------------------------ | | 65 | Method B| 1 | 1 | | 68 | Method A| 2 | 2 | | 70 | Method B| 3 | 3 | | 73 | Method B| 4 | 4 | | 75 | Method A| 5 | 5 | | 78 | Method A| 6 | 6 | | 80 | Method B| 7 | 7 | | 82 | Method A| 8 | 8 | | 85 | Method B| 9 | 9 | | 90 | Method A| 10 | 10 | | 92 | Method B| 11 | 11 | *(In this example, there are no ties, so initial and adjusted ranks are the same.)*

3

Sum Ranks for Each Group

Separate the ranked data back into their original groups and sum the ranks for each group. Let R₁ be the sum of ranks for Group 1 (Method A) and R₂ be the sum of ranks for Group 2 (Method B). **Example Rank Sums:** * **Method A Ranks:** 2, 5, 6, 8, 10 * **R₁ = 2 + 5 + 6 + 8 + 10 = 31** * **Method B Ranks:** 1, 3, 4, 7, 9, 11 * **R₂ = 1 + 3 + 4 + 7 + 9 + 11 = 35** *Self-check: The sum of all ranks (R₁ + R₂) should equal N(N+1)/2. Here, N=11, so 11(12)/2 = 66. R₁ + R₂ = 31 + 35 = 66. This matches, so our rank sums are correct.*

4

Calculate the U Statistics

Calculate the U statistic for each group using the following formulas: * `U₁ = n₁ * n₂ + (n₁ * (n₁ + 1)) / 2 - R₁` * `U₂ = n₁ * n₂ + (n₂ * (n₂ + 1)) / 2 - R₂` Where: * `n₁` = sample size of Group 1 * `n₂` = sample size of Group 2 * `R₁` = sum of ranks for Group 1 * `R₂` = sum of ranks for Group 2 The test statistic `U` for the Mann-Whitney U test is the *smaller* of U₁ and U₂. **Example U Statistics:** * `n₁ = 5`, `n₂ = 6` * `U₁ = (5 * 6) + (5 * (5 + 1)) / 2 - 31` * `U₁ = 30 + (5 * 6) / 2 - 31` * `U₁ = 30 + 15 - 31` * `U₁ = 45 - 31 = 14` * `U₂ = (5 * 6) + (6 * (6 + 1)) / 2 - 35` * `U₂ = 30 + (6 * 7) / 2 - 35` * `U₂ = 30 + 21 - 35` * `U₂ = 51 - 35 = 16` *Self-check: U₁ + U₂ should equal n₁ * n₂. Here, 14 + 16 = 30, and 5 * 6 = 30. This matches.* The smaller U value is `U = 14`.

5

Determine Critical Value and Make a Decision

To determine statistical significance, compare your calculated U statistic to a critical U value. For small sample sizes (typically when both n₁ and n₂ are less than 20), you consult a Mann-Whitney U critical value table using your n₁, n₂, and α level. If your calculated U is less than or equal to the critical U value, you reject the null hypothesis. For larger sample sizes (n₁ or n₂ > 20), the U distribution approximates a normal distribution, allowing for a Z-score calculation: * `Mean (μ_U) = (n₁ * n₂) / 2` * `Standard Deviation (σ_U) = √((n₁ * n₂ * (n₁ + n₂ + 1)) / 12)` * `Z = (U - μ_U) / σ_U` Then, compare the absolute value of the calculated Z-score to a critical Z-score (e.g., ±1.96 for α = 0.05, two-tailed). If |Z| is greater than the critical Z, reject H₀. Alternatively, you can find the p-value associated with your Z-score and compare it to α. **Example Decision (using table for small N):** For our example, `n₁ = 5` and `n₂ = 6`, with `α = 0.05` (two-tailed). Consulting a Mann-Whitney U critical value table for `n₁ = 5`, `n₂ = 6`, `α = 0.05` (two-tailed), the critical U value is 4. Our calculated `U = 14`. Since 14 is NOT less than or equal to 4, we fail to reject the null hypothesis.

6

State Your Conclusion

Based on your comparison, state your statistical conclusion in the context of your research question. If you reject the null hypothesis, you conclude that there is a statistically significant difference between the two groups. If you fail to reject the null hypothesis, you conclude that there is insufficient evidence to suggest a significant difference. **Example Conclusion:** Since our calculated U (14) is greater than the critical U value (4) for `n₁ = 5`, `n₂ = 6`, and `α = 0.05`, we **fail to reject the null hypothesis**. This means there is no statistically significant difference in test scores between students taught with Method A and those taught with Method B.

The Mann-Whitney U test, also known as the Wilcoxon rank-sum test, is a non-parametric statistical test used to determine if there is a significant difference between the distributions of two independent groups. It is an alternative to the independent samples t-test when the assumptions for the t-test (e.g., normality) are not met, or when data is ordinal.

This guide will walk you through the manual calculation of the Mann-Whitney U statistic, enabling you to understand its underlying principles and interpret its results.

Prerequisites

Before you begin, ensure you have:

  • Two Independent Samples: The data must come from two distinct, unrelated groups.
  • Ordinal or Continuous Data: The dependent variable should be measured on at least an ordinal scale. While it can be continuous, it does not need to be normally distributed.
  • Null and Alternative Hypotheses: Clearly define your hypotheses.
    • Null Hypothesis (H₀): The distributions of the two populations are identical (or, more commonly, that the medians are equal).
    • Alternative Hypothesis (H₁): The distributions of the two populations are not identical (or, the medians are not equal).
  • Significance Level (α): Typically set at 0.05, this is the probability of rejecting the null hypothesis when it is true.

Understanding the Mann-Whitney U Statistic

The Mann-Whitney U test works by ranking all observations from both groups combined and then comparing the sum of ranks for each group. The U statistic essentially quantifies the degree of overlap between the two distributions. A smaller U value indicates a greater difference between the groups.

Worked Example: Comparing Test Scores

Let's say we want to compare the effectiveness of two different teaching methods (Method A and Method B) on student test scores. We have the following scores:

  • Method A (n₁ = 5): 75, 82, 68, 90, 78
  • Method B (n₂ = 6): 70, 85, 65, 92, 73, 80

Hypotheses:

  • H₀: There is no difference in test scores between Method A and Method B.
  • H₁: There is a difference in test scores between Method A and Method B.
  • Significance Level (α): 0.05

Common Pitfalls to Avoid

  • Incorrectly Handling Ties: Always assign the average rank to tied values. Failing to do so will lead to incorrect U statistics and p-values.
  • Using for Dependent Samples: The Mann-Whitney U test is strictly for independent samples. For dependent samples, consider the Wilcoxon Signed-Rank Test.
  • Misinterpreting the Null Hypothesis: While often interpreted as a test of medians, the Mann-Whitney U test technically tests whether one distribution is stochastically larger than the other. If the shapes of the distributions are different, a significant U value doesn't necessarily mean different medians, although it often does for similarly shaped distributions.
  • Small Sample Size Limitations: For very small sample sizes (e.g., n₁ or n₂ < 5), the power of the test is low, and using a critical value table is essential as the normal approximation is inappropriate.

When to Use a Calculator for Convenience

While understanding the manual calculation is crucial for conceptual grasp, using a statistical software package or an online calculator is highly recommended for:

  • Large Sample Sizes: Manual ranking and calculation become tedious and prone to error with many data points.
  • Complex Tie Structures: When many values are tied, calculating average ranks can become cumbersome.
  • Exact P-values: Software provides precise p-values, which are more accurate than relying solely on critical value tables or Z-approximation for borderline cases.
  • Verification: After a manual calculation, a calculator can quickly verify your results, ensuring accuracy before drawing conclusions.

By following these steps and understanding the underlying principles, you can confidently perform and interpret the Mann-Whitney U test.

准备好计算了吗?

跳过手动工作并立即获得结果。

打开计算器

设置

隐私条款关于© 2026 PrimeCalcPro