Wilcoxon Zero Differences: Three Ways to Allocate Ranks
2026-11-17

Wilcoxon Zero Differences: Three Ways to Allocate Ranks

A zero difference in a paired comparison carries no positive or negative sign, yet it can still change the ranks assigned to the other differences. That distinction matters when a robot statistics report compares the same observations under different zero-handling settings. This reading of the current SciPy Wilcoxon signed-rank documentation follows one small, constructed set of differences through all three settings. The numbers below are teaching arithmetic, not robot trial results, and they do not establish statistical significance.

One zero creates two possible ranking populations

Take the ordered differences d = [-2, 0, 1, 3]. Keep that order as an observation identifier: the first difference is negative, the second is zero, and the last two are positive. Their absolute magnitudes are 2, 0, 1 and 3. Sorting magnitudes is a separate operation from assigning signs. In particular, the negative difference does not receive a negative rank; its positive rank will contribute to the negative-side sum.

The SciPy Wilcoxon API documentation distinguishes wilcox, which removes zeros before ranking, pratt, which ranks them but omits their ranks from the signed sums, and zsplit, which shares their rank contribution equally between the two sides. These conventions answer different questions about where the zero participates in the calculation.

For this example, either three magnitudes compete for ranks or all four do. If zero is absent, the sorted sequence is 1, 2, 3. If zero remains, it becomes 0, 1, 2, 3. Each nonzero value therefore moves up by one rank in the second sequence. Nothing about the measured direction has changed; only the ranking population has changed. Keeping these two sequences on paper makes the later sum differences easy to trace.

Remove the zero before assigning the wilcox ranks

Under wilcox, remove the second observation from the ranking operation. Magnitude 1 receives rank 1, magnitude 2 receives rank 2, and magnitude 3 receives rank 3. Put those ranks back beside their original differences: -2 has rank 2, +1 has rank 1, and +3 has rank 3. The zero has no rank in this calculation.

The positive-side sum is consequently 1 + 3 = 4. The negative-side sum is 2. Together they account for all available ranks: 4 + 2 = 6, which also equals 1 + 2 + 3. This equality is a useful arithmetic check on the example. A sum of 7 here would signal that some rank had been counted twice or that the four-observation ranking had accidentally entered the three-observation calculation.

Count and rank total describe different things. There are four original pairs, three nonzero differences, and six total rank units in the signed sums. Calling all three quantities the “sample total” would hide the operation that produced them. A worksheet can retain the original pair count while separately displaying the number of differences that participate in ranking.

Ranks in observation order for differences minus two, zero, plus one and plus three: wilcox gives two, omitted, one, three; Pratt and zsplit give three, one, two, four.
Hand-calculated absolute ranks for the constructed vector [-2, 0, 1, 3]. The zero row is retained visibly even when it is omitted from ranking. Source: Zhilianhai editorial desk, original AI-assisted mathematical illustration; no real product, trial or measured data.

Rank the zero, then omit its Pratt contribution

Under pratt, rank the full magnitude sequence. Zero receives rank 1, +1 receives rank 2, -2 receives rank 3, and +3 receives rank 4. Now omit the zero's rank from both signed sums. The positive side becomes 2 + 4 = 6; the negative side becomes 3. Their combined total is 9.

The full rank total was 1 + 2 + 3 + 4 = 10. The difference between 10 and 9 is exactly the omitted zero rank. That missing unit is deliberate. Assigning it to the positive side because zero is nonnegative would instead produce 7 and 3, which is not the Pratt calculation in this example. Assigning it to neither side does not undo the upward shift of the three nonzero ranks.

The SciPy implementation of the signed-rank calculation separates absolute-value ranking from the positive and negative sums. It also adjusts the normal approximation for Pratt's zero treatment. The sums illustrated here therefore explain the rank accounting, not a complete replacement formula for a p-value. This source is the development branch; a reproducible analysis should identify the installed SciPy version as well.

Split the same zero rank equally with zsplit

For zsplit, begin with the same four-observation ranks used for Pratt. Before allocating the zero contribution, the nonzero positive and negative sums are still 6 and 3. Zero's rank is 1, so each side receives half a rank unit. The resulting sums are 6.5 and 3.5.

Three relationships distinguish this result from the other two. First, the combined sum returns to the full rank total: 6.5 + 3.5 = 10. Second, the signed gap remains 3, because adding the same 0.5 to both sides leaves 6 - 3 unchanged. Third, the smaller sum increases from 3 under Pratt to 3.5 under zsplit. Equal additions preserve a difference while changing each individual total.

Fractions here do not imply half an observation. The four original pairs remain four pairs. A rank contribution has been divided, not a row of data. The diagram separates the positive and negative columns so that the shared addition can be followed without mistaking it for a new observation or a change to the original difference values.

Three signed-rank calculations compare wilcox positive four and negative two, Pratt six and three, and zsplit six point five and three point five; each zero-rank allocation is identified.
Signed sums calculated from the same four invented differences. These rank totals are not p-values or measurements of robot performance. Source: Zhilianhai editorial desk, original AI-assisted mathematical illustration; no real product, trial or measured data.

A returned statistic does not supply its own interpretation

For a two-sided call, the documented returned statistic is the smaller signed-rank sum. Our constructed example would therefore have statistics 2, 3 and 3.5 for wilcox, Pratt and zsplit respectively. Reversing every difference exchanges the two signed sums but preserves their minimum; it does not make the one-sided alternative interchangeable.

These three statistics are not three measures of improvement on a common scale. Their rank accounting differs. The API documentation treats p-value calculation separately and warns that zeros or tied magnitudes affect the null distribution, so selecting method='exact' with such data does not by itself establish an exact p-value. No p-value is calculated for this teaching example.

In an actual report, specify the direction of subtraction and how a zero was determined. The documentation also warns that floating-point subtraction can separate values intended to tie. Any rounding decision should follow the measurement definition rather than being chosen to obtain a preferred result. Readers can place this note beside the site's robotics data analysis collection and use the current statistics article index to compare other reports' stated conventions. The key audit trail is the actual difference vector, its ranking population, and the allocation of zero ranks.

18028484626 CONTACT US

公司:智联海(惠州)科技有限公司

地址:惠州仲恺高新区陈江街道白云山工业大道 5 号六楼 601

Q Q:18028484626

Copyright © 2002-2026

粤xxx

咨询 在线留言 电话:18028484626
微信 微信扫码添加我