SnDispersion[list]
gives the
statistic of the elements in list.
SnDispersion[list,c]
gives the
statistic with scaling factor c.
SnDispersion
SnDispersion[list]
gives the
statistic of the elements in list.
SnDispersion[list,c]
gives the
statistic with scaling factor c.
Details and Options
- SnDispersion is a robust measure of dispersion.
- SnDispersion is a rank-based estimator with its statistic based on absolute pairwise differences. The statistic does not require location estimation.
- For the list {x1,x2,…,xn}, the value of
estimator is given by the median of {zi,1≤i≤n} multiplied by a scaling factor c, where zi is the median of {xi– xj,1≤j≤n} over j. - When c is not specified, a positive scaling factor c* that satisfies
is applied to make
statistic a consistent estimator of the scale parameter for normally distributed data. Also, a finite sample correction is used by default to make the estimator unbiased for small samples. - SnDispersion[{{x1,y1,…},{x2,y2,…},…}] gives {SnDispersion[{x1,x2,…}],SnDispersion[{y1,y2,…}],…}.
- SnDispersion supports a Method option. The following explicit settings can be specified:
-
"FiniteSample" uses finite sample correction (default) "None" no correction - The option Method is ignored if the scaling factor c is specified in the input.
Examples
open all close allBasic Examples (4)
SnDispersion of a list:
SnDispersion[{6.5, 3.8, 6.6, 5.7, 6.0, 6.4, 5.3}]SnDispersion of columns of a matrix:
SnDispersion[{{1., 2.}, {4., 8.}, {5., 3.}, {2., 15.}}]SnDispersion of a list with scaling factor 1:
SnDispersion[{1, 2, 3, 2, 1}, 1]SnDispersion of a list of dates:
SnDispersion[{Yesterday, Today, Tomorrow}]Scope (8)
Exact input yields exact output when the scaling factor is exact:
SnDispersion[{1, 20, 3, 4}, 1]SnDispersion[{Sqrt[2], E, Pi, Pi ^ 2, 1, 2, 3}, 2]SnDispersion with different scaling parameters:
SnDispersion[{1.2, 3.8, 4.2, -0.5, -5.2}, 3]SnDispersion[{1.2, 3.8, 4.2, -0.5, -5.2}, 4]SnDispersion for a matrix gives a columnwise estimate:
SnDispersion[RandomReal[1, {50, 3}]]SnDispersion of a large array:
SnDispersion[RandomReal[1, 10 ^ 6]]SnDispersion[RandomReal[1, {10 ^ 6, 2}]]Find the SnDispersion of a TimeSeries:
ts = TemporalData[TimeSeries, {{{3, 8, 4, 11, 9, 2}}, {{{1, 3, 5, 7, 8, 10}}}, 1, {"Continuous", 1},
{"Discrete", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False,
10.1];SnDispersion[ts]SnDispersion depends only on the values:
SnDispersion[ts["Values"]]SnDispersion works with data involving quantities:
data = Quantity[RandomReal[1, 6], "Meters"]SnDispersion[data]Compute SnDispersion of dates:
dates = WolframLanguageData[All, "DateIntroduced"];DateHistogram[dates]SnDispersion[dates]UnitConvert[%, "Years"]Compute SnDispersion of times:
RandomTime[3]SnDispersion[%]List of times with different time zone specifications:
{TimeObject[{12}, TimeZone -> 0], TimeObject[{12}, TimeZone -> 2], TimeObject[{12}, TimeZone -> "Asia/Tokyo"]}SnDispersion[%]Options (1)
Applications (6)
Obtain a robust estimate of dispersion when extreme values are present:
SnDispersion[{3, 10, 10 ^ 6, 20, 5, 6}]Sample standard deviation is heavily influenced by extreme values:
StandardDeviation[{3, 10, 10 ^ 6, 20, 5, 6}]//NIdentify periods of high volatility in stock data using a five-year moving
dispersion:
data = TemporalData[«4»];smooth = Sqrt[MovingMap[SnDispersion, data, {Quantity[5, "Year"]}]];DateListPlot[smooth]Compute
dispersion for slices of a collection of paths of a random process:
data = RandomFunction[WienerProcess[], {0, 1, .01}, 10 ^ 3];times = Range[0, 1, .1];sd = Map[{#, SnDispersion[data["SliceData", #]]}&, times];Plot
dispersion over these paths:
Show[ListPlot[data], ListLinePlot[sd, PlotStyle -> Black]]Find the
dispersion of the heights for the children in a class:
heights = Quantity[{134, 143, 131, 140, 145, 136, 131, 136, 143, 136, 133, 145, 147,
150, 150, 146, 137, 143, 132, 142, 145, 136, 144, 135, 141}, "Centimeters"];ListPlot[heights, Filling -> Axis, AxesLabel -> Automatic]snd = SnDispersion[heights]Plot the
dispersion with respect to the median:
md = Median[heights];
n = Length[heights];ListPlot[{heights, {{0, md}, {n, md}}, {{0, md - snd}, {n, md - snd}}, {{0, md + sd}, {n, md + sd}}}, Filling -> {1 -> 0, 3 -> {4}}, Joined -> {False, True, True, True}, PlotStyle -> {Automatic, Automatic, Gray, Gray}, PlotLegends -> {"heights", "median", "Sn-bands"}, AxesLabel -> Automatic]Consider data from standard normal distribution with outliers modeled by another normal distribution with large spread:
BlockRandom[
SeedRandom[10];
data = RandomVariate[MixtureDistribution[{0.95, 0.05}, {NormalDistribution[], NormalDistribution[0, 10]}], 10 ^ 4];
]Test the data against standard normal distribution:
DistributionFitTest[data, NormalDistribution[], "TestConclusion"]sd = SnDispersion[data]Remove outliers by selecting data points that are within three times the
dispersion from the sample median:
med = Median[data];ndata = Pick[data, Sign[Abs[data - med] - 3 sd], -1];Test the new data against standard normal distribution:
DistributionFitTest[ndata, NormalDistribution[], "TestConclusion"]Generate data from a Student t distribution:
data = RandomVariate[StudentTDistribution[1, 2, 1], 10 ^ 4];Histogram[data, {0.5}]Compute the dispersion of the data with three measures: standard deviation, square root of trimmed variance and
dispersion:
ests = {StandardDeviation, Sqrt[TrimmedVariance[#]]&, SnDispersion};{sd, tsd, sn} = Through[ests[data]]Assess the accuracy of these three dispersion estimators via bootstrapping:
res = Table[Through[ests[RandomChoice[data, Length[data]]]], {10 ^ 3}];
estimator gives the smallest spread with the given data:
StandardDeviation[res]Properties & Relations (2)
SnDispersion is a rank-based dispersion estimator with its statistic based on pairwise absolute differences:
data = RandomReal[1, 100];
diffs = Abs[Outer[Subtract, data, data]];Compute the low median of high medians using RankedMin:
RankedMin[RankedMin[#, 51]& /@ diffs, 50]Compare with SnDispersion with scaling factor equal to 1:
SnDispersion[data, 1]QnDispersion, SnDispersion and StandardDeviation are estimators of the scale parameter of NormalDistribution:
data = RandomVariate[NormalDistribution[1, 2], 10 ^ 4];
est = {QnDispersion, SnDispersion, StandardDeviation};TableForm[Through[est[data]], TableHeadings -> {est}]Assess the accuracy of the estimators via bootstrapping:
{qnerror, snerror, stderror} = Variance[Table[Through[est[RandomChoice[data, 10 ^ 4]]], {10 ^ 3}]];Compute the relative efficiencies with respect to StandardDeviation using the estimated results:
{stderror / qnerror, stderror / snerror}Related Guides
Text
Wolfram Research (2017), SnDispersion, Wolfram Language function, https://reference.wolfram.com/language/ref/SnDispersion.html (updated 2024).
CMS
Wolfram Language. 2017. "SnDispersion." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/SnDispersion.html.
APA
Wolfram Language. (2017). SnDispersion. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SnDispersion.html
BibTeX
@misc{reference.wolfram_2026_sndispersion, author="Wolfram Research", title="{SnDispersion}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/SnDispersion.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_sndispersion, organization={Wolfram Research}, title={SnDispersion}, year={2024}, url={https://reference.wolfram.com/language/ref/SnDispersion.html}, note=[Accessed: 12-June-2026]}