Sign test (source code)

= Sign test
{wiki}

The <sign test> uses only the signs of <independent random variables>[independent] differences $D_1,\ldots,D_n$. Under the <Null hypothesis> $\mathbb P(D_i>0)=\mathbb P(D_i<0)=1/2$ and no ties, the count $S=\sum_i\mathbf1_{\{D_i>0\}}$ has the <binomial distribution> $\operatorname{Binomial}(n,1/2)$. It can test a continuous population <median> against a specified value, or a <median> paired difference against zero, without specifying the magnitude <probability distribution>[distribution] of the differences.

For a two-sided test, one conventional exact <p-value> is $\min\{1,2\min[\mathbb P(B\leq S),\mathbb P(B\geq S)]\}$ for $B\sim\operatorname{Binomial}(n,1/2)$. Seven positive differences among eight give $2\mathbb P(B\geq7)=18/256\simeq0.0703$. The test is robust to the sizes of extreme differences because only signs are used, but discarding magnitudes can lose <statistical power>[power] relative to a suitable parametric test.

With zero differences, deleting ties gives an exact conditional sign calculation when the nonzero signs are equally likely under the <Null hypothesis>. For a discrete population, merely declaring zero a <median> does not by itself imply that conditional sign symmetry. Dependence between pairs also invalidates the <independent random variables>[independent] binomial calculation.