Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

Parametric vs Nonparametric Tests in Python: Choose the Right SciPy Method

A practical guide to choosing common SciPy tests by whether samples are independent or paired, how many groups you have, and whether the target is means or distributions.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a statistical test based on how observations are related and what you want to compare—not simply on whether the data look normal. In SciPy, an independent-samples t-test compares means, Mann–Whitney U compares distributions using ranks, Wilcoxon signed-rank handles paired observations, and Kruskal–Wallis provides a rank-based omnibus test for multiple independent groups. Their hypotheses differ, so they are not interchangeable substitutes.

Start with the study design and the question

Before choosing a test, answer two questions: Are the observations independent or paired, and what quantity should the analysis compare? A test can be computationally correct yet answer the wrong question if it ignores the study design or targets a different quantity than intended.

As an Amazon Associate I earn from qualifying purchases.

  • Independent groups: Each observation belongs to one group, and observations are not paired across groups.
  • Paired observations: Each value in one sample is meaningfully linked to a value in the other—for example, measurements from the same participants at two times.
  • Target: Decide whether the question concerns average values, or whether the groups’ distributions differ.

SciPy’s statistical test reference organizes functions by common uses and sample structures, while noting that no broad index can cover every use case.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which SciPy test fits common group comparisons?

Design and target SciPy method What to keep in mind
Two independent groups; compare means scipy.stats.ttest_ind Tests equality of average values. Its default, equal_var=True, assumes identical population variances.
Two independent groups; compare distributions using ranks scipy.stats.mannwhitneyu The null is that the underlying distributions are the same. It is not universally a test of medians.
Two related or paired samples scipy.stats.wilcoxon Tests paired differences; the documented null describes differences as symmetric about zero.
Several independent groups; rank-based omnibus comparison scipy.stats.kruskal Small group sizes can make the chi-square approximation inappropriate. A significant omnibus result does not identify which groups differ.
Several groups; mean-based comparison One-way ANOVA SciPy lists this option; select it according to the model, design, target, and assumptions.

For current signatures and details, consult the official SciPy references for ttest_ind, mannwhitneyu, wilcoxon, and kruskal.

Independent samples: t-test or Mann–Whitney U?

Use an independent t-test when the target is a difference in means

scipy.stats.ttest_ind compares the average values of two independent samples. Its default assumes equal population variances. If that assumption is not appropriate for your analysis, make the variance choice explicit with equal_var=False; do not let the default silently determine the model you intended. The SciPy documentation also describes a permutation method, whose availability and calling convention should be checked against the version you use.

from scipy import stats

result = stats.ttest_ind(group_a, group_b, equal_var=False)
print(result.statistic, result.pvalue)

This example makes the unequal-variance choice explicit. The returned result includes a test statistic and p-value; neither alone communicates the estimated effect or its practical importance.

Use Mann–Whitney U when a rank-based distribution comparison fits

scipy.stats.mannwhitneyu is for two independent samples. Its null hypothesis concerns equality of the underlying distributions. It is often used to assess a location difference, but calling it a universal median test overstates what it establishes: a median-focused interpretation requires additional conditions on the distributions’ shapes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
result = stats.mannwhitneyu(group_a, group_b)
print(result.statistic, result.pvalue)

A rank-based test is not simply a t-test with a normality switch flipped. The methods have different hypotheses and target different features of the data. Choose the one aligned with the scientific question rather than selecting whichever returns the preferred p-value.

Paired measurements: use the paired structure

For two related samples, SciPy documents scipy.stats.wilcoxon, the paired rank-based option. The analysis concerns within-pair differences, and the documented null describes those differences as symmetric about zero.

result = stats.wilcoxon(before, after)
print(result.statistic, result.pvalue)

Keep the observations in corresponding order so each pair remains intact. Running an independent-samples test on these values discards the pairing and analyzes a different design.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

More than two independent groups

Kruskal–Wallis is an omnibus rank-based test

scipy.stats.kruskal compares several independent groups using ranks. SciPy cautions that group sizes must not be too small for its chi-square approximation to be appropriate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
result = stats.kruskal(group_a, group_b, group_c)
print(result.statistic, result.pvalue)

A significant omnibus result indicates evidence against the overall null, but it does not say which particular groups differ. Plan a suitable follow-up analysis separately, accounting for the fact that multiple comparisons may be involved.

For a mean-based question, consider one-way ANOVA

SciPy’s statistical-functions index also lists one-way ANOVA for comparisons involving multiple groups. The index is a starting point, not a complete decision rule: choose the model and procedure in light of the design, target, and assumptions.

A practical selection sequence

  1. Identify the design. Determine whether groups are independent or measurements are paired.
  2. State the target. Decide whether you are comparing means or asking about distributions with a rank-based method.
  3. Match the number of groups. For two independent groups, consider ttest_ind or mannwhitneyu; for paired samples, consider wilcoxon; for several independent groups, consider Kruskal–Wallis for a rank-based omnibus comparison or ANOVA for a mean-based question.
  4. Check assumptions and implementation choices. In particular, decide whether the equal-variance default in ttest_ind is appropriate, and verify method details in the documentation for your installed SciPy version.
  5. Plan interpretation and follow-up. Report what the test evaluates, and remember that an omnibus result does not locate group differences.

These common choices do not cover every design, such as every repeated-measures or more complex model. When the observations or question do not fit the cases above, consult SciPy’s statistical functions index and select a method designed for that structure.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.