The sign test is a non-parametric test used to compare the distribution median with a given value *m*. This test could be used as an alternative for one-sample Student t-test. Unlike the t-test, the sign test can work with non-normal distributions.

The sign test has only one requirement: scale of measurement^{[1]} should be ordinal, interval or ratio (i.e. test could not be applied to nominal variables). This is the only restriction. On the one hand, this makes the test as widely applicable as possible. On the other hand, this lowers its effectiveness, because the test cannot use any assumptions about distribution properties.

**Note #1**

Sign test is not very powerful on small samples. This happens because the test uses only information about element positions relative to the assumed median: to the left or to the right. The test doesn't use information about their values. Fortunately, there is a more powerful test - the Wilcoxon signed-rank test. It uses information about elements' rank. Unfortunately, the scope of this test is limited by distributions which are symmetric relative to the median. With non-symmetric distributions, the test works incorrectly, so we are to use a less powerful sign test.

Subroutine **OneSampleSignTest** returns three p-values:

- p-value for two-tailed test (null hypothesis - median is equal to the given number)
- p-value for left-tailed test (null hypothesis - median is greater than or equal to the given number)
- p-value for right-tailed test (null hypothesis - median is less than or equal to the given number)

The test algorithm is simple. All elements which are equal to *m* are thrown out. After that we have elements of two types only: elements which are greater than *m* (*N ^{ +}* elements) and which are less than

C++ | `stest` subpackage | |

C# | `stest` subpackage |

*This article is intended for personal use only.*

C# source.

C++ source.

C++ source. MPFR/GMP is used.

GMP source is available from gmplib.org. MPFR source is available from www.mpfr.org.

FreePascal version.

Delphi version.

VB.NET version.

VBA version.

Python version (CPython and IronPython are supported).

ALGLIB® - numerical analysis library, 1999-2017.

ALGLIB is a registered trademark of the ALGLIB Project.

Policies for this site: privacy policy, trademark policy.

ALGLIB is a registered trademark of the ALGLIB Project.

Policies for this site: privacy policy, trademark policy.