SignedRankTest[data]
tests whether the median of data is zero.
SignedRankTest[{data1,data2}]
tests whether the median of data1-data2 is zero.
SignedRankTest[dspec,μ0]
tests a location measure against μ0.
SignedRankTest[dspec,μ0,"property"]
returns the value of "property".
SignedRankTest
SignedRankTest[data]
tests whether the median of data is zero.
SignedRankTest[{data1,data2}]
tests whether the median of data1-data2 is zero.
SignedRankTest[dspec,μ0]
tests a location measure against μ0.
SignedRankTest[dspec,μ0,"property"]
returns the value of "property".
Details and Options
- SignedRankTest tests the null hypothesis
against the alternative hypothesis
: -


data 

{data1,data2} 

- where μ is the population median for data and μ12 is the median of the paired differences of the two datasets
. - By default, a probability value or
-value is returned. - A small
-value suggests that it is unlikely that
is true. - The data in dspec can be univariate {x1,x2,…} or multivariate {{x1,y1,…},{x2,y2,…},…}.
- If two samples are given, they must be of equal length.
- The argument μ0 can be a real number or a real vector with length equal to the dimension of the data.
- SignedRankTest assumes that the data is symmetric about the median in the univariate case and elliptically symmetric in the multivariate case. For this reason, SignedRankTest is also a test of means.
- SignedRankTest[dspec,μ0,"HypothesisTestData"] returns a HypothesisTestData object htd that can be used to extract additional test results and properties using the form htd["property"].
- SignedRankTest[dspec,μ0,"property"] can be used to directly give the value of "property".
- Properties related to the reporting of test results include:
-
"DegreesOfFreedom" the degrees of freedom used in a test "PValue" list of
-values"PValueTable" formatted table of
-values"ShortTestConclusion" a short description of the conclusion of a test "TestConclusion" a description of the conclusion of a test "TestData" list of pairs of test statistics and
-values"TestDataTable" formatted table of
-values and test statistics"TestStatistic" list of test statistics "TestStatisticTable" formatted table of test statistics - The SignedRankTest is a more powerful alternative to the SignTest.
- For univariate samples, SignedRankTest performs the Wilcoxon signed rank test for medians of paired samples. A correction for ties is applied for permutation-based
-values. By default, the test statistic is corrected for continuity and an asymptotic result is returned. - For multivariate samples, SignedRankTest performs an affine invariant test for paired samples using standardized spatial signed ranks. The test statistic is assumed to follow a ChiSquareDistribution[dim] where dim is the dimension of the data.
- The following options can be used:
-
AlternativeHypothesis "Unequal" the inequality for the alternative hypothesis MaxIterations Automatic max iterations for multivariate median tests Method Automatic the method to use for computing
-valuesSignificanceLevel 0.05 cutoff for diagnostics and reporting VerifyTestAssumptions Automatic what assumptions to verify - For the SignedRankTest, a cutoff
is chosen such that
is rejected only if
. The value of
used for the "TestConclusion" and "ShortTestConclusion" properties is controlled by the SignificanceLevel option. This value
is also used in diagnostic tests of assumptions including a test for symmetry. By default,
is set to 0.05. - Named settings for VerifyTestAssumptions in SignedRankTest include:
-
"Symmetry" verify that all data is symmetric
Examples
open all close allBasic Examples (4)
Test whether the median of a population is zero:
data = RandomVariate[NormalDistribution[], 100];DistributionChart[data]SignedRankTest[data]Compare the median difference for paired data to a particular value:
data = RandomVariate[MultinormalDistribution[{2, 0}, {{1, .75}, {.75, 1}}], 1000];BoxWhiskerChart[Transpose@data]SignedRankTest[Transpose@data, 2]Report the test results in a table:
SignedRankTest[Transpose@data, 2, "TestDataTable"]Test whether the spatial median of a multivariate population is some value:
data = RandomVariate[MultinormalDistribution[{4, 5, 6}, IdentityMatrix[3]], 10^2];SignedRankTest[data, {4, 5, 6}]SignedRankTest[data, {4, 5, 6}, "TestStatistic"]Create a HypothesisTestData object for repeated property extraction:
data = RandomVariate[StudentTDistribution[4], 100];ℋ = SignedRankTest[data, Automatic, "HypothesisTestData"]A list of available properties:
ℋ["Properties"]Extract a single property or a list of properties:
ℋ["TestData"]ℋ["TestDataTable", "PValue", "TestStatistic"]Scope (13)
Testing (10)
data1 = RandomVariate[NormalDistribution[0, 1], 500];
data2 = RandomVariate[NormalDistribution[3, 1], 500];The
-values are typically large when the median is close to μ0:
SignedRankTest[data1]The
-values are typically small when the location is far from μ0:
SignedRankTest[data2]Using Automatic is equivalent to testing for a median of zero:
data = RandomVariate[NormalDistribution[0, 1], 500];SignedRankTest[data, 0]SignedRankTest[data, Automatic]data1 = RandomVariate[NormalDistribution[3, 1], 500];
data2 = RandomVariate[NormalDistribution[0, 1], 500];The
-values are typically large when median is close to μ0:
SignedRankTest[data1, 3]The
-values are typically small when the location is far from μ0:
SignedRankTest[data2, 3]Test whether the median vector of a multivariate population is the zero vector:
data = RandomVariate[MultinormalDistribution[{.1, 0, -.5, 0}, IdentityMatrix[4]], 10^2];SignedRankTest[data]Alternatively, test against {0.1,0,-.5,0}:
SignedRankTest[data, {0.1, 0, -.5, 0}]data1 = RandomVariate[NormalDistribution[0, 1], 100];
data2 = RandomVariate[NormalDistribution[1, 1], 100];
data3 = RandomVariate[NormalDistribution[0, 2], 100];The
-values are generally small when the locations are not equal:
SignedRankTest[{data1, data2}, 0]The
-values are generally large when the locations are equal:
SignedRankTest[{data1, data3}, 0]data1 = RandomVariate[NormalDistribution[3, 1], 100];
data2 = RandomVariate[NormalDistribution[0, 1], 100];The order of the datasets affects the test results:
SignedRankTest[{data1, data2}, 3]SignedRankTest[{data2, data1}, 3]Test whether the median difference vector of two multivariate populations is the zero vector:
data1 = RandomVariate[MultinormalDistribution[{.5, 0, -.5, 0}, IdentityMatrix[4]], 10^2];data2 = RandomVariate[MultinormalDistribution[{-.5, 0, .5, 0}, IdentityMatrix[4]], 10^2];SignedRankTest[{data1, data2}]Alternatively, test against {1,0,-1,0}:
SignedRankTest[{data1, data2}, {1, 0, -1, 0}]Create a HypothesisTestData object for repeated property extraction:
data = RandomVariate[NormalDistribution[], {2, 10^4}];ℋ = SignedRankTest[data, 0, "HypothesisTestData"];The properties available for extraction:
ℋ["Properties"]Extract some properties from a HypothesisTestData object:
data = RandomVariate[NormalDistribution[], {2, 10^4}];ℋ = SignedRankTest[data, 0, "HypothesisTestData"];The
-value and test statistic:
ℋ["PValue"]ℋ["TestStatistic"]Extract any number of properties simultaneously:
data = RandomVariate[NormalDistribution[], {2, 10^4}];ℋ = SignedRankTest[data, 0, "HypothesisTestData"];The
-value and test statistic:
ℋ["PValue", "TestStatistic"]Reporting (3)
data = RandomVariate[NormalDistribution[], {2, 20}];ℋ = SignedRankTest[data, 0, "HypothesisTestData"];ℋ["TestDataTable"]Retrieve the entries from a test table for customized reporting:
data = RandomVariate[NormalDistribution[], {1000, 25}];res = Table[SignedRankTest[i, 0, "TestData", VerifyTestAssumptions -> None], {i, data}];ListPlot[res, PlotStyle -> PointSize[Medium]]Tabulate
-values or test statistics:
data = RandomVariate[NormalDistribution[], {2, 10^2}];ℋ = SignedRankTest[data, 0, "HypothesisTestData"];ℋ["PValueTable"]ℋ["PValue"]ℋ["TestStatisticTable"]The test statistic from the table:
ℋ["TestStatistic"]Options (12)
AlternativeHypothesis (3)
A two-sided test is performed by default:
data = RandomVariate[NormalDistribution[], {2, 100}];SignedRankTest[data, 0, AlternativeHypothesis -> "Unequal"]SignedRankTest[data, 0, AlternativeHypothesis -> Automatic]Perform a two-sided test or a one-sided alternative:
data = RandomVariate[NormalDistribution[], {2, 100}];SignedRankTest[data, 0, AlternativeHypothesis -> "Unequal"]SignedRankTest[data, 0, AlternativeHypothesis -> "Less"]SignedRankTest[data, 0, AlternativeHypothesis -> "Greater"]Perform tests with one-sided alternatives when μ0 is given:
data1 = RandomVariate[NormalDistribution[2.9, 1], 1000];
data2 = RandomVariate[NormalDistribution[0, 1], 1000];Mean[data1 - data2]SignedRankTest[{data1, data2}, 3, AlternativeHypothesis -> "Less"]SignedRankTest[{data1, data2}, 2.9, AlternativeHypothesis -> "Less"]MaxIterations (2)
Set the maximum number of iterations to use for multivariate tests:
data1 = RandomVariate[BinormalDistribution[.5], 25];
data2 = RandomVariate[BinormalDistribution[.5], 25];By default, 500 iterations are allowed:
SignedRankTest[{data1, data2}, Automatic, MaxIterations -> 500]SignedRankTest[{data1, data2}, Automatic, MaxIterations -> Automatic]Setting the maximum number of iterations may result in lack of convergence:
BlockRandom[SeedRandom[2];
data1 = RandomVariate[BinormalDistribution[.5], 25];
data2 = RandomVariate[BinormalDistribution[.5], 25];]The
-values are not equivalent:
SignedRankTest[{data1, data2}, Automatic, MaxIterations -> 1]SignedRankTest[{data1, data2}, Automatic, MaxIterations -> Automatic]Method (4)
By default,
-values are computed using asymptotic test statistic distributions:
data = RandomVariate[NormalDistribution[], {2, 100}];SignedRankTest[data, 0, Method -> Automatic]SignedRankTest[data, 0, Method -> "Asymptotic"]Permutation methods can be used:
data = RandomVariate[NormalDistribution[], {2, 35}];SignedRankTest[data, 0, Method -> "Asymptotic"]SignedRankTest[data, 0, Method -> "Permutation"]Set the number of permutations to use:
data = RandomVariate[NormalDistribution[], {2, 35}];SignedRankTest[data, 0, Method -> {"Permutation", "MonteCarloSamples" -> 10^3}]SignedRankTest[data, 0, Method -> {"Permutation", "MonteCarloSamples" -> 10^5}]By default,
random permutations are used:
SignedRankTest[data, 0, Method -> {"Permutation", "MonteCarloSamples" -> 10^4}]Set the seed used for generating random permutations:
data = RandomVariate[NormalDistribution[], {2, 35}];SignedRankTest[data, 0, Method -> {"Permutation", "RandomSeed" -> 0}]SignedRankTest[data, 0, Method -> {"Permutation", "RandomSeed" -> 9}]SignificanceLevel (1)
The significance level is used for "TestConclusion" and "ShortTestConclusion":
BlockRandom[SeedRandom[1];data = RandomVariate[NormalDistribution[0, 1], {2, 100}]];ℋ1 = SignedRankTest[data, .2, "HypothesisTestData", SignificanceLevel -> .05];ℋ2 = SignedRankTest[data, .2, "HypothesisTestData", SignificanceLevel -> .001];ℋ1["TestConclusion"]//TraditionalFormℋ2["TestConclusion"]//TraditionalFormℋ1["ShortTestConclusion"]ℋ2["ShortTestConclusion"]VerifyTestAssumptions (2)
Diagnostics can be controlled as a group using All or None:
data1 = RandomVariate[ExponentialDistribution[1], 100];
data2 = RandomVariate[ExponentialDistribution[1], 100];SignedRankTest[{data1, data2}, 0, VerifyTestAssumptions -> All]SignedRankTest[{data1, data2}, 0, VerifyTestAssumptions -> None]Diagnostics can be controlled independently:
data1 = RandomVariate[ExponentialDistribution[1], 1000];
data2 = RandomVariate[ExponentialDistribution[1], 1000];SignedRankTest[{data1, data2}, 0, VerifyTestAssumptions -> "Symmetry"]Set the symmetry assumption to True:
SignedRankTest[{data1, data2}, 0, VerifyTestAssumptions -> "Symmetry" -> True]Applications (1)
Twelve sets of identical twins were given psychological tests to measure aggressiveness. It is hypothesized that the first-born twin will tend to be more aggressive than the second-born:
first = {86, 71, 77, 68, 91, 72, 77, 91, 70, 71, 88, 87};
second = {88, 77, 76, 64, 96, 72, 65, 90, 65, 80, 81, 72};BarChart[first - second]There is insufficient evidence to reject
that birth order has no effect on aggressiveness:
SignedRankTest[{first, second}, 0, "TestDataTable", AlternativeHypothesis -> "Greater"]Properties & Relations (8)
The SignedRankTest is generally more powerful than the SignTest:
data = RandomVariate[NormalDistribution[1, 1], {250, 15}];Subscript[p, SR] = Table[SignedRankTest[i, VerifyTestAssumptions -> None], {i, data}];
Subscript[p, SGN] = Table[SignTest[i], {i, data}];Probability[x ≤ .05, xSubscript[p, SR]]//NProbability[x ≤ .05, xSubscript[p, SGN]]//NThe univariate Wilcoxon signed rank test statistic:
data = RandomVariate[NormalDistribution[], 100];Subscript[μ, 0] = 0;In the absence of ties, Ordering can be used to compute ranks:
WSR[data_, μ0_] := With[{dat = data - μ0}, Total[Pick[Sign[dat] * Ordering[Ordering[Abs@dat]], Sign[dat], 1]]]WSR[data, Subscript[μ, 0]]SignedRankTest[data, Subscript[μ, 0], "TestDataTable"]The asymptotic two-sided
-value:
WSRP[data_] := With[{ranks = Sign[data] Ordering[Ordering[Abs[data]]], d = NormalDistribution[]}, 2. Min[CDF[d, (Total[ranks] + 1/Sqrt[ranks.ranks])], SurvivalFunction[d, (Total[ranks] - 1/Sqrt[ranks.ranks])]]]WSRP[data - Subscript[μ, 0]]For univariate data, the test statistic is asymptotically normal:
data = RandomVariate[NormalDistribution[], {1000, 100}];T = Table[Quiet@SignedRankTest[i, Automatic, "TestStatistic"], {i, data}];DistributionFitTest[T, NormalDistribution[μ, σ]]For multivariate data, the test statistic follows a ChiSquareDistribution under
:
data = RandomVariate[BinormalDistribution[.5], {250, 15}];T = Table[SignedRankTest[i, Automatic, "TestStatistic"], {i, data}];The degree of freedom is equal to the dimension of the data:
df = Dimensions[data[[1]]][[2]]DistributionFitTest[T, ChiSquareDistribution[df]]For multivariate data, the SignedRankTest effectively tests uniformity about a unit sphere:
μ = {{0, 0}, {.5, .5}, {1, 1}, {10, 10}};data = Table[RandomVariate[ProductDistribution[NormalDistribution[i[[1]], 1], NormalDistribution[i[[2]], 1]], 100], {i, μ}];A function for computing the spatial signed ranks of a matrix:
SSR[data_] := Block[{n, p, item, dmt, dpt, dm, dp, out = {}}, {n, p} = Dimensions[data];Do[dmt = dpt = Table[0., {p}];Do[dm = i - j;dp = i + j;dmt = dmt + (If[#1 == 0, dm, (dm/#1)]&)[Sqrt[dm.dm]];dpt = dpt + (If[#1 == 0, dp, (dp/#1)]&)[Sqrt[dp.dp]];, {j, data}];item = (dmt + dpt/2 n);out = Join[{item}, out], {i, data}];out]Deviations from μ0 yield clustering of spatial signed ranks and larger test statistics:
Table[Show[ListPlot[SSR[i], AspectRatio -> 1, PlotStyle -> PointSize[Medium], PlotLabel -> Row[{"SR: ", SignedRankTest[i, Automatic, "TestStatistic"]}], PlotRange -> {{-1, 1}, {-1, 1}}], Graphics[Circle[]]], {i, data}]The test statistic is affine invariant for multivariate data:
data = RandomVariate[MultinormalDistribution[{0, 0}, IdentityMatrix[2]], 100];𝒯 = AffineTransform[{{{1, 2}, {3, 4}}, {1, 2}}];SignedRankTest[data, {0, 0}, "TestDataTable"]SignedRankTest[𝒯[data], 𝒯[{0, 0}], "TestDataTable"]The signed rank test works with the values only when the input is a TimeSeries:
ts = TemporalData[TimeSeries, {{{1.224578634529677, 0.47929635789978015, 0.6572781300178168,
0.21496048742669355, 0.7299608014554928, -0.2495111111278263, -1.3286551762002712,
0.552725018274874, 0.19272112205837066, 1.1809144012420882, -1.1671 ... 40938613662046, 1.052394590214582, 0.9345044123980388, 0.38537803109557855,
-0.48660931166089394, -0.71203560340161}}, {{0, 100, 1}}, 1, {"Continuous", 1},
{"Discrete", 1}, 1, {ValueDimensions -> 1, ResamplingMethod -> None}}, False, 10.1];SignedRankTest[ts]SignedRankTest[ts["Values"]]The signed rank test works with all the values together when the input is a TemporalData:
td = TemporalData[Automatic, {{{-0.25275046867718637, -0.7175779198306353, -1.9370139837317764,
0.006665621735740701, -0.3730807122324292, 0.6740106823161018, 0.8562214990564344,
0.955785083955732, 1.7020898014886303, 1.8523009430646802, 0.244 ... 3951759101545, -1.1611722313627828, 1.1602446901533021,
1.1052173095128992, 1.1089143920161917, -0.13837156328402}}, {{0, 100, 1}}, 2,
{"Continuous", 2}, {"Discrete", 1}, 1, {ValueDimensions -> 1, ResamplingMethod -> None}}, False,
10.1];SignedRankTest[td]data = td["ValueList"]//Flatten;
SignedRankTest[data]Test the difference of the medians of the two paths:
{data1, data2} = td["ValueList"];SignedRankTest[{data1, data2}]Possible Issues (1)
SignedRankTest requires that the data be symmetric about a common median:
BlockRandom[SeedRandom[3];data1 = RandomVariate[NormalDistribution[], 100];
data2 = RandomVariate[ExponentialDistribution[2], 100]];SignedRankTest[{data1, data2}, VerifyTestAssumptions -> "Symmetry"]Use SignTest if the data is not symmetric:
SignTest[{data1, data2}]Neat Examples (1)
Compute the statistic when the null hypothesis
is true:
data1 = RandomVariate[NormalDistribution[], {2500, 100}];
data2 = RandomVariate[NormalDistribution[], {2500, 100}];T1 = MapThread[SignedRankTest[{#1, #2}, 0, "TestStatistic"]&, {data1, data2}];The test statistic given a particular alternative:
T2 = MapThread[SignedRankTest[{#1, #2}, 1, "TestStatistic"]&, {data1, data2}];Compare the distributions of the test statistics:
SmoothHistogram[{T1, T2}, Filling -> Axis, PlotLegends -> {"SubscriptBox[H, 0] is True", "SubscriptBox[H, 0] is False"}]Related Guides
History
Text
Wolfram Research (2010), SignedRankTest, Wolfram Language function, https://reference.wolfram.com/language/ref/SignedRankTest.html.
CMS
Wolfram Language. 2010. "SignedRankTest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SignedRankTest.html.
APA
Wolfram Language. (2010). SignedRankTest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SignedRankTest.html
BibTeX
@misc{reference.wolfram_2026_signedranktest, author="Wolfram Research", title="{SignedRankTest}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/SignedRankTest.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_signedranktest, organization={Wolfram Research}, title={SignedRankTest}, year={2010}, url={https://reference.wolfram.com/language/ref/SignedRankTest.html}, note=[Accessed: 13-June-2026]}