ds@mcpanalytics.aiEmail your data and your question and get an answer about your own data, with the method shown.Email your data and question. Get an answer.

t-Test vs Mann-Whitney U: Which Should You Use?

By MCP Analytics Team | Published , updated

Have three or more groups to compare? The group comparison tool uses ANOVA and Kruskal-Wallis, the multi-group tests discussed in this guide. →

Picture a made-up case. An analyst runs a Shapiro-Wilk test on A/B test data, gets a small p-value, and switches from a t-test to the Mann-Whitney U. The result changes from significant to not significant, and the analyst concludes the effect is not real. The analyst may have made the wrong call by mechanically following the "test for normality first" recipe, because the t-test can still work with non-normal data and a failed normality test alone does not settle the choice.

Choosing between the t-test and the Mann-Whitney U is one of the most common decisions in applied statistics, and it is frequently made poorly. The textbook rule, "use Mann-Whitney when data is non-normal", oversimplifies the decision. This guide explains what each test compares, when a t-test may work with non-normal data, and how to choose a test that fits the question.

Worked Example (Simulated): Do Checkout Times Differ Between Two Flows?

Question: Do checkout times differ between two flows?

Inputs: Simulated data, seed 20261029. The script makes two independent groups of 30 checkout times in seconds. It uses a lognormal draw to make the times right-skewed. The gap is built in: the log-means are 4.0 for group A and 3.8 for group B. Group A has a higher mean and median in this run.

Method: Compare means with Welch's t-test. Compare rank order with the two-sided Mann-Whitney U test. The tie-adjusted chance is the share of all A and B pairs where A is higher, with ties counted as half.

import numpy as np
from scipy import stats

SEED = 20261029
rng = np.random.default_rng(SEED)
# Simulated checkout time in seconds for two independent flow groups.
a = rng.lognormal(mean=4.0, sigma=0.65, size=30)
b = rng.lognormal(mean=3.8, sigma=0.65, size=30)

welch = stats.ttest_ind(a, b, equal_var=False)
u = stats.mannwhitneyu(a, b, alternative='two-sided', method='auto')
# Tie-adjusted probability that a randomly picked A value exceeds B.
diffs = a[:, None] - b[None, :]
p_super = (np.sum(diffs > 0) + 0.5 * np.sum(diffs == 0)) / diffs.size

print(f'Simulated data, seed {SEED}')
print(f'Each group: n={len(a)} independent sessions; unit=seconds')
print(f'A mean={np.mean(a):.2f}; median={np.median(a):.2f}')
print(f'B mean={np.mean(b):.2f}; median={np.median(b):.2f}')
print(f"Welch t={welch.statistic:.3f}; p={welch.pvalue:.4f}")
print(f'Mann-Whitney U={u.statistic:.1f}; two-sided p={u.pvalue:.4f}')
print(f'Tie-adjusted P(A > B)={p_super:.3f}')

Printed output:

Simulated data, seed 20261029
Each group: n=30 independent sessions; unit=seconds
A mean=68.42; median=54.55
B mean=51.51; median=45.07
Welch t=1.727; p=0.0899
Mann-Whitney U=552.0; two-sided p=0.1335
Tie-adjusted P(A > B)=0.613

Result: In this run, the Welch test gives p=0.0899 and the Mann-Whitney test gives p=0.1335. The two flows differ by design, and with 30 sessions each neither test finds it at the usual 0.05 cut-off, which is a convention the analyst picks. That is a missed gap, not proof of no gap. The pair chance is 0.613, so A is higher in more than half of the pairs in this sample.

Limit: These are made-up times and one sample. They do not show how real users would act, and they do not show that a flow caused a change.

Sources

Each source is cited for which test is which. No number on this page rests on them.

How these numbers were produced: the platform figures in this article come from a sample run of our group comparison tool on the Kaggle Students Performance in Exams dataset (n = 1,000, matching the dataset's published constants: overall math mean 66.09). The tool ran classical ANOVA, Welch's ANOVA, and the Kruskal-Wallis test (the multi-group analogs of the t-test vs Mann-Whitney decision) side by side. Run sample_standard_group_comparison_1786049294_c6d24f2c4d66, checked 2026-08-06. Computed in R.

What Each Test Does

The Independent Samples t-Test

The t-test compares the means of two independent groups. It calculates the difference between group means, divides by the standard error of that difference, and checks whether the resulting t-statistic is large enough to be unlikely under the null hypothesis of equal population means.

The t-test works best when the sampling distribution of the mean is close to normal. This is guaranteed when the data itself is normal. For non-normal data, the Central Limit Theorem says that, as the sample grows, the sampling distribution of the mean tends to become more normal. How fast this happens depends on the data shape, and strong skew and heavy tails can need much larger samples.

The Mann-Whitney U Test

The Mann-Whitney U (also called the Wilcoxon rank-sum test) works on ranks rather than raw values. It pools all observations from both groups, ranks them from smallest to largest, and tests whether one group tends to have higher ranks than the other.

The Mann-Whitney test uses ranks and does not assume normal data. It compares the groups' rank distributions. A location or median reading needs the groups to have the same shape. It also discards information about the magnitude of differences between values: the gap between ranks 1 and 2 is the same whether the actual values differ by 0.1 or 1000.

Side-by-Side Comparison

Feature t-Test Mann-Whitney U
Tests for Difference in means Stochastic dominance: one group tends to give larger values
Data type Continuous (interval/ratio) Ordinal or continuous
Normality assumption Works best when the sampling distribution of the mean is close to normal No
Equal variance assumption Yes (Welch's t-test relaxes this) Similar shape assumed for median interpretation
Uses The values themselves The ranks of the values
Handles outliers Sensitive (outliers inflate variance) Robust (ranks cap outlier influence)
Handles ties Not applicable Uses correction for ties (common with ordinal data)
Effect size Cohen's d (mean difference in SD units) Rank-biserial correlation or common language effect size

When the t-Test Is Robust Enough

The t-test can hold up better than many practitioners expect. How well it holds up depends on the data shape, the outliers, and the sample size.

The t-test works well even with non-normal data when:

Key insight: The Shapiro-Wilk normality test should not be used as a gatekeeper for the t-test. With small samples, it lacks power to detect non-normality. With large samples (where the t-test is robust anyway), it rejects normality for trivial deviations. Visual inspection with a Q-Q plot is more informative.

When Mann-Whitney Is Necessary

There are genuine scenarios where the Mann-Whitney is the correct choice:

Common misconception: "Mann-Whitney tests medians." This is only true when both groups have the same distribution shape. If the distributions differ in shape or spread, Mann-Whitney can reject the null hypothesis even when the medians are identical. It actually tests whether a randomly selected observation from group A is equally likely to be greater or less than a randomly selected observation from group B.

Power and Outliers

Power is the chance a test finds a gap that is really there. It depends on the data, the sample size, and the size of the gap, and neither test is more powerful in every case. Because the Mann-Whitney test works on ranks, extreme values have limited influence on it. Outliers can inflate the variance the t-test uses. Revenue data with a few very large customers is one place where this matters.

Illustrative Numbers: A/B Test on Session Duration

These numbers are typed in by hand to show how the two tests can disagree. They are not from a real site. Two checkout flows are compared on time to complete checkout (seconds), 40 sessions per group.

The Data Problem

Session durations are right-skewed: most users finish in 30-90 seconds, but some abandon and return later (producing values of 300-900 seconds). The Shapiro-Wilk test rejects normality (p < 0.001).

t-Test Result

Group A mean: 78.3s (SD = 62.1)
Group B mean: 64.1s (SD = 55.8)
t(78) = 1.07, p = 0.287
Cohen's d = 0.24

Mann-Whitney Result

Group A median: 52s (IQR: 35-89)
Group B median: 41s (IQR: 28-72)
U = 604, p = 0.041
Rank-biserial r = 0.245

Here the Mann-Whitney detects a significant difference that the t-test misses. Why? The handful of extreme session durations (users who left and returned) inflate the standard deviations, making the t-test's denominator large. The Mann-Whitney, working on ranks, is unaffected by the magnitude of those outliers. For data like this, a rank test may fit the question better.

From our platform: real numbers. The checkout scenario above is illustrative; here is the same decision playing out on a real run. We ran our group comparison tool on the Kaggle Students Performance in Exams dataset (n = 1,000) to test whether math scores differ by parental education. The group means matched an independent recompute exactly (master's degree 69.746 vs high school 62.138). Classical ANOVA gave F = 6.52, and Welch's ANOVA and the Kruskal-Wallis test (the rank-based test, the multi-group analog of Mann-Whitney) agreed on the conclusion. The deciding moment: the Shapiro-Wilk check flagged a normality violation, so the report led with the rank-based result instead of the classical one. That is precisely the parametric-vs-rank-based decision this article teaches, made by the tool on real data. Verification run sample_standard_group_comparison_1786049294_c6d24f2c4d66, 2026-08-06.

Decision Guide

Use the t-test when:

Use Mann-Whitney when:

Consider alternatives when:

Your turn

Bring your own data and the question you actually need answered.

MCP AnalyticsData science by email Send us your data and your question, and we will reply. ds@mcpanalytics.ai

Frequently Asked Questions

Is the Mann-Whitney U test the same as the Wilcoxon rank-sum test?

Yes, they are mathematically equivalent. Different software uses different names: SciPy has both mannwhitneyu() and ranksums(), R uses wilcox.test(). Do not confuse the Wilcoxon rank-sum (for independent samples) with the Wilcoxon signed-rank test (for paired samples).

How large does my sample need to be for the t-test to be robust?

There is no single number. The needed size depends on the data. A larger sample can help the t-test, but strong skew or heavy tails (exponential, log-normal) can need much larger samples, and Mann-Whitney may fit better.

Does Mann-Whitney test medians or mean ranks?

Mann-Whitney tests stochastic dominance: whether one group tends to produce larger values than the other. It is commonly described as a test of medians, but this interpretation is only valid when both groups have the same distribution shape. When shapes differ, Mann-Whitney can reject the null even when medians are equal.

Should I run a normality test before choosing?

Running a normality test as a gatekeeper is common but statistically questionable. With small samples, normality tests lack power. With large samples, they reject for trivial deviations. Instead, examine your data visually (histogram, Q-Q plot), consider the variable type (ordinal? bounded?), and use domain knowledge about the expected distribution.