ADescribe · Guide test 122
Baumgartner–Weiss–Schindler test
Compares two independent distributions with a variance weighted rank discrepancy that emphasizes tails.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Compare distributions (two or more groups) — Do the groups come from the same distribution — anywhere, not only in their centers?
In Compare distributions (two or more groups), choose Test = Baumgartner–Weiß–Schindler.
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Baumgartner–Weiss–Schindler test
Your data
Drag a point or use ↑/↓ to change itIf H₀ were true
- The reference: how B varies across samples when H₀ is true, 999 relabelings of the pooled values (permutation null on the shared Wichmann–Hill stream).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .008).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- sorted pooled ranks of the first sample
- variance weights that stress the tails
The verdict
B = 4.18, p = .008
p ≤ α = .050: reject H₀
A rank version of Anderson–Darling's tail weighting, often more powerful than KS or CvM. The p relabels the pooled sample on the shared stream.
- Statistic
- 4.178
- p-value
- 0.0080
Baumgartner–Weiss–Schindler test on Group 1: n = 20; Group 2: n = 20: B = 4.18, p = .008. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: two independent samples have identical distributions.
Assumptions
Independent samples with ordinal/continuous measurements; permutation calibration handles ties appropriately.
Formula
Parameters and notation
Ri are pooled ranks of sorted X; BY swaps m,n and uses sorted Y pooled ranks. Finite sample variants may modify centering.
Structure of the method
Rank pooled observations, form each group’s ordered-rank departures and weight them by a rank-dependent variance expression. Averaging the two group components produces a symmetric statistic with greater relative emphasis near distribution tails.
Estimated and nuisance parameters
Pooled ranks and group sizes are data-derived quantities. No distributional mean, variance or density bandwidth is fitted. Finite-sample centering choices identify the particular BWS implementation.
Settings and design choices
Choose the implementation variant, rank-tie policy, alternative and exact/Monte Carlo permutation method. Prespecify sample exclusions and resampling count; do not compare unstandardized variants as if their statistic scales were identical.
Fitting and adaptation
Use randomization of labels under the common-distribution null, preserving group sizes and observed values. Recompute ranks or reuse their equivalent fixed pooled representation consistently. Applying the method to new data requires recomputation and calibration, not model fitting. When pairs or clusters are the independent units, ordinary individual-label permutations do not apply.
Sensitivity and robustness
Tail weights can make a few extreme ranks influential, while large tied blocks change rank information. A rejection indicates distributional disagreement without specifying location versus scale. Multiple BWS tests across outcomes or subgroup searches require multiplicity control even though the underlying test is nonparametric.
How to use and calibrate
Use the BWS statistic’s label permutation distribution; large B signals distributional differences.
Example application
Compare distributions with a rank discrepancy that emphasizes tails.
Interpretation and pitfalls
Watch out
Do not compare B with a chi square distribution without a justified approximation. State the implementation variant.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
- Rewritten in the review: Python output.
- Not in the correction log: The v4 import had truncated the Python output; edition 2 restores it (B = 3.0727, p = 0.015); not in the correction log.
Python and R
Two-sided Baumgartner–Weiss–Schindler discrepancy; random permutations use the plus-one Monte Carlo p-value.
Validated — Executed successfully in the validation environment · needs numpy, scipy
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
x = np.array([4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0])
y = np.array([4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9])
print(stats.bws_test(x,y,method=stats.PermutationMethod(n_resamples=999,rng=rng)))
Output
2034201, 0.95788666, 0.46863492, 0.97862351, 0.73605332,
2.67226339, 0.78091815, 0.76510293, 0.81671999, 0.14020635,
0.56655729, 0.53942832, 2.66830208, 1.07981696, 1.61351339,
1.04107416, 0.55656399, 0.65478646, 0.42494048, 0.6664003 ,
1.57714137, 0.89882713, 1.87039831, 0.42295982, 0.88907391,
2.86516716, 0.5118192 , 0.45684102, 0.61937475, 1.44857887,
1.1761188 , 1.94986458, 0.60373958, 0.20322718, 0.61133209,
1.27992312, 0.75910094, 1.31857589, 0.86134474, 0.53051538,
2.33387153, 1.86919792, 0.8025253 , 1.28367436, 0.40882515,
1.00575248, 0.47892832, 1.18788269, 0.75670015, 0.52673413,
0.86650645, 0.36600099, 0.69508978, 3.13645685, 0.69959127,
0.63543006, 1.13683581, 0.29514757, 1.79312277, 0.78752034,
0.59413641, 4.08356994, 1.06400174, 0.54780109, 1.55340352,
0.42647098, 0.70808408, 1.60595089, 0.75129836, 1.37934598,
0.36047917, 1.17524851, 0.62846776, 1.06181101, 0.37617436,
2.64432416, 2.07578621, 1.09914335, 0.37473388, 0.76786384,
1.32565823, 0.38304663, 0.7054432 , 0.44900843, 0.56979836,
1.33490129, 0.34436384, 0.57303943, 0.22231349, 1.0463559 ,
0.36888194, 0.43487376, 2.00676339, 0.57411979, 0.60518006,
1.34714534, 0.41053571, 0.41485714, 0.7786374 , 1.02342832,
0.61958482, 0.62180556, 1.0772061 , 0.36047917, 0.29118626,
0.76489286, 1.66248958, 0.54492014, 0.2144809 , 0.46515377,
0.37725471, 0.50914831, 0.22087302, 0.64938467, 1.71374653,
0.98333507, 1.12231101, 1.06853323, 0.87133805, 0.55422321,
0.6655 , 0.30730159, 0.93832019, 0.50914831, 0.80840724,
0.72320908, 1.14238765, 0.53681746, 0.92652629, 0.3385119 ,
1.22674554, 0.35276662, 0.36248983, 4.79780605, 0.8143192 ,
1.19181399, 2.82063244, 0.63062847, 0.79475273, 2.40901637,
2.61104315, 0.44954861, 2.27505208, 0.49984524, 0.299469 ,
1.6924995 , 0.7105749 , 0.35408705, 1.01766642, 0.43919519,
0.14020635, 1.14862971, 0.9676999 , 0.89342535, 0.37185293,
0.45876166, 0.30586111, 2.24816319, 0.37185293, 0.60518006,
0.38652778, 0.51145908, 1.28367436, 1.3791059 , 2.1643755 ,
0.41053571, 0.53750769, 1.66645089, 0.53051538, 1.09194097,
0.30586111, 1.58470387, 0.87130804, 0.9676999 , 0.47892832,
2.33579216, 0.45684102, 2.41453819, 0.45023884, 1.34045313,
0.79415253, 0.50128571, 0.5296751 , 0.28389385, 1.07501538,
0.37725471, 1.790812 , 0.32203646, 1.40176339, 0.6158936 ,
0.38796825, 0.30298016, 0.62873785, 1.2587061 , 0.47892832,
0.62846776, 2.35983011, 0.3385119 , 0.90566939, 0.90098785,
0.55215253, 0.31078274, 0.36248983, 0.28821528, 0.56067535,
0.96914038, 0.54347966, 0.53891815, 0.92427555, 1.54187971,
0.78457937, 2.31430506, 0.37617436, 0.85813368, 0.44900843,
0.83160491, 0.61178224, 1.95970784, 1.01127431, 0.22087302,
0.46863492, 1.18788269, 0.55779439, 0.49552381, 0.82368229,
0.62297594, 1.68805804, 0.64938467, 0.33211979, 0.59203571,
0.64866443, 1.08413839, 0.47787798, 0.45684102, 0.68299578,
0.95632614, 0.39577083, 0.80987773, 0.65739732, 0.51842138,
2.22571577, 1.83846776, 2.41453819, 0.38013566, 0.54780109,
0.85381225, 0.46224281, 1.28052331, 2.06810367, 0.3914494 ,
0.50914831, 0.39288988, 0.39577083, 2.61104315, 0.35960888,
1.10409499, 1.33454117, 0.51986186, 0.81647991, 0.73953447,
0.30586111, 0.1948244 , 2.0863497 , 0.53111558, 0.55959499,
0.70832416, 0.70625347, 1.11765947, 1.06649256, 2.81054911,
0.20907912, 1.40404415, 0.86773686, 0.73977455, 0.22519444,
0.61178224, 0.1948244 , 0.40909524, 0.59635714, 0.36600099,
0.48769122, 0.82908408, 0.61565352, 0.95176463, 0.53249603,
1.23490823, 1.39759201, 0.78463938, 0.96914038, 1.321937 ,
0.43187277, 0.85345213, 0.38013566, 1.00719296, 0.77554638,
0.14020635, 2.01792708, 3.09267237, 0.50362649]))Validated — Executed successfully in the validation environment · needs Base/standard library
x <- c(4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0)
y <- c(4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9)
bws<-function(a,b) {n<-length(a);m<-length(b);r<-rank(c(a,b));i<-seq_len(n);j<-seq_len(m)
B1<-mean((sort(r[i])-(n+m)*i/n)^2/((i/(n+1))*(1-i/(n+1))*m*(n+m)/n))
B2<-mean((sort(r[n+j])-(n+m)*j/m)^2/((j/(m+1))*(1-j/(m+1))*n*(n+m)/m));(B1+B2)/2}
T<-bws(x,y);pool<-c(x,y);n<-length(x);set.seed(2026);B<-999
null<-replicate(B,{z<-sample(pool);bws(z[seq_len(n)],z[-seq_len(n)])})
print(c(B=T,p=(1+sum(null>=T))/(B+1)))
Output
B p 3.072716 0.038000
Sources
- SciPy Baumgartner–Weiss–Schindler testdocs.scipy.org
- scipy.stats.bws_testdocs.scipy.org
- Statistics guide v4 (historical):
- R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 122, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT122.