QnDispersion[list]
gives the
statistic of the elements in list.
QnDispersion[list,c]
gives the
statistic with a scaling factor c.
QnDispersion
QnDispersion[list]
gives the
statistic of the elements in list.
QnDispersion[list,c]
gives the
statistic with a scaling factor c.
Details and Options
- QnDispersion is a robust measure of dispersion.
- QnDispersion 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 the
statistic is given by the first quartile of the set {xi– xj,i<j} multiplied by a scaling factor c. - When c is not specified, a scaling factor
is applied to make the
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. - QnDispersion[{{x1,y1,…},{x2,y2,…},…}] gives {QnDispersion[{x1,x2,…}],QnDispersion[{y1,y2,…}],…}.
- QnDispersion 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)
QnDispersion of a list:
QnDispersion[{6.5, 3.8, 6.6, 5.7, 6.0, 6.4, 5.3}]QnDispersion of columns of a matrix:
QnDispersion[{{1., 2.}, {4., 8.}, {5., 3.}, {2., 15.}}]QnDispersion of a list with scaling factor 1:
QnDispersion[{1, 2, 3, 2, 1}, 1]QnDispersion of a list of dates:
QnDispersion[{Yesterday, Today, Tomorrow}]Scope (8)
Exact input yields exact output when the scaling factor is exact:
QnDispersion[{1, 20, 3, 4}, 1]QnDispersion[{Sqrt[2], E, Pi, Pi ^ 2, 1, 2, 3}, 2]QnDispersion with different scaling parameters:
QnDispersion[{1.2, 3.8, 4.2, -0.5, -5.2}, 3]QnDispersion[{1.2, 3.8, 4.2, -0.5, -5.2}, 4]QnDispersion for a matrix gives a columnwise estimate:
QnDispersion[RandomReal[1, {50, 3}]]QnDispersion of a large array:
QnDispersion[RandomReal[1, 10 ^ 6]]QnDispersion[RandomReal[1, {10 ^ 6, 2}]]Find a QnDispersion 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];QnDispersion[ts]The
dispersion depends only on the values:
QnDispersion[ts["Values"]]QnDispersion works with data involving quantities:
data = Quantity[RandomReal[1, 6], "Meters"]QnDispersion[data]Compute QnDispersion of dates:
dates = WolframLanguageData[All, "DateIntroduced"];DateHistogram[dates]QnDispersion[dates]UnitConvert[%, "Years"]Compute QnDispersion of times:
RandomTime[3]QnDispersion[%]List of times with different time zone specifications:
{TimeObject[{12}, TimeZone -> 0], TimeObject[{12}, TimeZone -> 2], TimeObject[{12}, TimeZone -> "Asia/Tokyo"]}QnDispersion[%]Options (1)
Applications (6)
Obtain a robust estimate of dispersion when extreme values are present:
QnDispersion[{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[QnDispersion, 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];qd = Map[{#, QnDispersion[data["SliceData", #]]}&, times];Plot
dispersion over these paths:
Show[ListPlot[data], ListLinePlot[qd, PlotStyle -> Red]]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]qd = QnDispersion[heights]Plot the
dispersion with respect to the median:
md = Median[heights];
n = Length[heights];ListPlot[{heights, {{0, md}, {n, md}}, {{0, md - qd}, {n, md - qd}}, {{0, m + qd}, {n, m + qd}}}, Filling -> {1 -> 0, 3 -> {4}}, Joined -> {False, True, True, True}, PlotStyle -> {Automatic, Automatic, Gray, Gray}, PlotLegends -> {"heights", "median", "Qn-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"]qd = QnDispersion[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 qd], -1];Test the new data against standard normal distribution:
DistributionFitTest[ndata, NormalDistribution[], "TestConclusion"]Generate data from a Student
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[#]]&, QnDispersion};{sd, tsd, qn} = 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)
QnDispersion is a rank-based dispersion estimator with its statistic based on pairwise absolute differences:
data = RandomReal[1, 100];
diffs = Flatten[Outer[Subtract, data, data]];Pick the positive values among the differences and compute the order statistic using RankedMin:
diffs = Pick[diffs, Sign[diffs], 1];
RankedMin[diffs, Binomial[Quotient[100, 2] + 1, 2]]Compare with QnDispersion with scaling factor equal to 1:
qn = QnDispersion[data, 1]Histogram of pairwise differences with a red line indicating the value of the
statistic:
Histogram[diffs, {0.05}, Epilog -> {Red, Thick, Line[{{qn, 0}, {qn, 480}}], Red, Text["Qn", {qn, 510}]}, PlotRange -> {0, 550}]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), QnDispersion, Wolfram Language function, https://reference.wolfram.com/language/ref/QnDispersion.html (updated 2024).
CMS
Wolfram Language. 2017. "QnDispersion." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/QnDispersion.html.
APA
Wolfram Language. (2017). QnDispersion. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/QnDispersion.html
BibTeX
@misc{reference.wolfram_2026_qndispersion, author="Wolfram Research", title="{QnDispersion}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/QnDispersion.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_qndispersion, organization={Wolfram Research}, title={QnDispersion}, year={2024}, url={https://reference.wolfram.com/language/ref/QnDispersion.html}, note=[Accessed: 12-June-2026]}