Skip to content

Add brunner_munzel(): nonparametric test for stochastic equality (Brunner & Munzel 2000)#515

Open
hass-nation wants to merge 1 commit into
raphaelvallat:mainfrom
hass-nation:feat/brunner-munzel
Open

Add brunner_munzel(): nonparametric test for stochastic equality (Brunner & Munzel 2000)#515
hass-nation wants to merge 1 commit into
raphaelvallat:mainfrom
hass-nation:feat/brunner-munzel

Conversation

@hass-nation

Copy link
Copy Markdown

Summary

Adds brunner_munzel(x, y) — the Brunner-Munzel test, a nonparametric test for stochastic equality of two independent groups. It is more robust than the Wilcoxon rank-sum / Mann-Whitney U test under heteroscedasticity (unequal variances), which is its main practical advantage.

Algorithm

Uses a Welch-Satterthwaite degrees-of-freedom approximation and a t-distribution reference. The test statistic is based on within-group and between-group rank differences. p-values are verified to match scipy.stats.brunnermunzel.

Interface

from pingouin import brunner_munzel

brunner_munzel(x, y, alternative='two-sided')
# Returns DataFrame with columns: W-val, dof, alternative, p-val, RBC, CLES
# CLES = P(X > Y), the common language effect size
# RBC  = rank-biserial correlation

New content

  • brunner_munzel() function added to pingouin/nonparametric.py and exported from pingouin/__init__.py
  • 11 tests added to tests/test_nonparametric.py covering: basic correctness vs scipy, identical groups, clear-difference groups, one-sided alternatives, effect size bounds, all three nan_policy modes, output column names

Reference

Brunner, E. & Munzel, U. (2000). The nonparametric Behrens-Fisher problem: asymptotic theory and a small-sample approximation. Biometrical Journal, 42(1), 17–25.

Implements the Brunner-Munzel test for stochastic equality of two independent
groups, with Welch-Satterthwaite degrees of freedom, CLES and RBC effect sizes,
and full nan_policy support. Adds 11 tests covering basic accuracy vs scipy,
one-sided alternatives, NaN handling, effect size range, and column schema.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.30435% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.26%. Comparing base (2d906c5) to head (42cab22).

Files with missing lines Patch % Lines
src/pingouin/nonparametric.py 91.30% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #515      +/-   ##
==========================================
- Coverage   98.36%   98.26%   -0.10%     
==========================================
  Files          19       19              
  Lines        3305     3351      +46     
  Branches      488      495       +7     
==========================================
+ Hits         3251     3293      +42     
- Misses         32       34       +2     
- Partials       22       24       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raphaelvallat

Copy link
Copy Markdown
Owner

Hi,

Thanks for opening the PR. Brunner Munzel is already supported by scipy.stats, so I don't see a strong reason to add it to Pingouin (I'm not sure what the value add would be), unless others feel strongly about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants