InterquartileRange[data]
gives the difference between the upper and lower quartiles
for the elements in data.
InterquartileRange[data,{{a,b},{c,d}}]
uses the quantile definition specified by parameters a, b, c, d.
InterquartileRange[dist]
gives the difference between the upper and lower quartiles
for the distribution dist.
InterquartileRange
InterquartileRange[data]
gives the difference between the upper and lower quartiles
for the elements in data.
InterquartileRange[data,{{a,b},{c,d}}]
uses the quantile definition specified by parameters a, b, c, d.
InterquartileRange[dist]
gives the difference between the upper and lower quartiles
for the distribution dist.
Details
- InterquartileRange is also known as IQR.
- InterquartileRange is a robust measure of dispersion, which means it is not very sensitive to outliers.
- InterquartileRange[data] is given by
, where
is given by Quartiles[data]. » - For MatrixQ data, the interquartile range is computed for each column vector with InterquartileRange[{{x1,y1,…},{x2,y2,…},…}], equivalent to {InterquartileRange[{x1,x2,…}],InterquartileRange[{y1,y2,…}]}. »
- For ArrayQ data, the interquartile range is equivalent to ArrayReduce[InterquartileRange,data,1]. »
- InterquartileRange[data,{{a,b},{c,d}}] uses the Quartiles definition specified by parameters a, b, c, d. »
- Common choices of parameters {{a,b},{c,d}} include:
-
{{0, 0}, {1, 0}} inverse empirical CDF {{0, 0}, {0, 1}} linear interpolation (California method) {{1/2, 0}, {0, 0}} element numbered closest to p n {{1/2, 0}, {0, 1}} linear interpolation (hydrologist method; default) {{0, 1}, {0, 1}} mean‐based estimate (Weibull method) {{1, -1}, {0, 1}} mode‐based estimate {{1/3, 1/3}, {0, 1}} median‐based estimate {{3/8, 1/4}, {0, 1}} normal distribution estimate - The default choice of parameters is {{1/2,0},{0,1}}. »
- The data can have the following additional forms and interpretations:
-
Association the values (the keys are ignored) » SparseArray as an array, equivalent to Normal[data] » QuantityArray quantities as an array » WeightedData based on the underlying EmpiricalDistribution » EventData based on the underlying SurvivalDistribution » TimeSeries, TemporalData, … vector or array of values (the time stamps ignored) » Image,Image3D RGB channel's values or grayscale intensity value » Audio amplitude values of all channels » DateObject, TimeObject list of dates or list of times » - InterquartileRange[dist] is given by
, where
is given by Quartiles[dist]. » - For a random process proc, the interquartile range function can be computed for a slice distribution at time t, SliceDistribution[proc,t], as InterquartileRange[SliceDistribution[proc,t]]. »
Examples
open all close allBasic Examples (3)
Interquartile range for a list of exact numbers:
InterquartileRange[{1, 3, 4, 2, 5, 6}]Interquartile range for a list of dates:
RandomDate[4, DateGranularity -> "Month"]//SortInterquartileRange[%]Interquartile range of a parametric distribution:
InterquartileRange[ExponentialDistribution[λ]]Scope (22)
Basic Uses (8)
Exact input yields exact output:
InterquartileRange[{1, 2, 3, 4}]InterquartileRange[{π, E, 2}]//TogetherApproximate input yields approximate output:
InterquartileRange[{1., 2., 3., 4.}]InterquartileRange[N[{1, 2, 3, 4}, 30]]Compute results using other parametrizations:
InterquartileRange[{-1, 5, 10, 4, 25, 2, 1}]InterquartileRange[{-1, 5, 10, 4, 25, 2, 1}, {{0, 0}, {1, 0}}]Find the interquartile range for WeightedData:
InterquartileRange[WeightedData[{1, 2, 3}, {3, 7, 4}]]data = {8, 3, 5, 4, 9, 0, 4, 2, 2, 3};
weights = {0.15, 0.09, 0.12, 0.10, 0.16, 0., 0.11, 0.08, 0.08, 0.09};InterquartileRange[WeightedData[data, weights]]Find the interquartile range for EventData:
e = {1.0, 2.1, 3.2, 4.5, 5.7};
ci = {0, 0, 0, 1, 0};InterquartileRange[EventData[e, ci]]Find the interquartile range for TemporalData:
s1 = {2, 1, 6, 5, 7, 4};
s2 = {4, 7, 5, 6, 1, 2};
t = {1, 2, 5, 10, 12, 15};td = TemporalData[{s1, s2}, {t}];InterquartileRange[td[10]]Find the interquartile range of TimeSeries:
InterquartileRange[TemporalData[TimeSeries, {{{2.3, 1.2, 6.7, 5.8, 7.1, 4.6}}, {{0, 5, 1}}, 1, {"Discrete", 1},
{"Discrete", 1}, 1, {}}, False, 10.]]The interquartile range depends only on the values:
InterquartileRange[TemporalData[TimeSeries, {{{2.3, 1.2, 6.7, 5.8, 7.1, 4.6}}, {{0, 5, 1}}, 1, {"Discrete", 1},
{"Discrete", 1}, 1, {}}, False, 10.]["Values"]]Find the interquartile range for data involving quantities:
data = Quantity[RandomReal[1, 6], "Meters"]InterquartileRange[data]Array Data (5)
InterquartileRange for a matrix gives columnwise ranges:
InterquartileRange[{{3, 5}, {1, 8}, {5, 6}, {7, 8}, {2, 4}}]Interquartile range for a tensor works across the first index:
InterquartileRange[RandomReal[1, {10, 2, 3}]]InterquartileRange[RandomReal[1, 10 ^ 7]]InterquartileRange[RandomReal[1, {10 ^ 6, 5}]]When the input is an Association, InterquartileRange works on its values:
mat = RandomReal[1, {3, 2}];
assoc = AssociationThread[Range[3], mat]InterquartileRange[assoc]SparseArray data can be used just like dense arrays:
sp = SparseArray[{{i_, i_} :> i, {i_, j_} /; j < i :> (i + j) ^ 2}, {100, 10}]InterquartileRange[sp]Find interquartile range of a QuantityArray:
data = QuantityArray[RandomReal[1, 6], "Pounds"]InterquartileRange[data]Image and Audio Data (2)
Channelwise interquartile range values of an RGB image:
InterquartileRange[[image]]Interquartile range intensity value of a grayscale image:
InterquartileRange[[image]]Interquartile range amplitude of all channels:
a = ExampleData[{"Audio", "Bee"}]InterquartileRange[a]Date and Time (4)
Compute interquartile range of dates:
dates = WolframLanguageData[All, "DateIntroduced"];DateHistogram[dates]InterquartileRange[dates]UnitConvert[%, "Years"]Compute the weighted interquartile range of dates:
dates = RandomDate[4]weights = {1, 1, 1, 3};InterquartileRange[WeightedData[dates, weights]]Compare the simple interquartile range:
InterquartileRange[dates]UnitConvert[%, "Days"]Compute the interquartile range of dates given in different calendars:
dates = {DateObject[{2024, 2, 29}, CalendarType -> "Julian"], DateObject[{1524, 1, 1}, CalendarType -> "Islamic"], DateObject[{6024, 1, 15}, CalendarType -> "Jewish"]}InterquartileRange[dates]UnitConvert[%, "Years"]Compute the interquartile range of times:
RandomTime[3]InterquartileRange[%]List of times with different time zone specifications:
{TimeObject[{12}, TimeZone -> 0], TimeObject[{12}, TimeZone -> 2], TimeObject[{12}, TimeZone -> "Asia/Tokyo"]}InterquartileRange[%]Distributions and Processes (3)
Find the interquartile range for a parametric distribution:
InterquartileRange[NormalDistribution[μ, σ]]Interquartile range for a derived distribution:
InterquartileRange[TransformedDistribution[x^2, xNormalDistribution[]]]data = RandomVariate[NormalDistribution[], 10 ^ 3];InterquartileRange[HistogramDistribution[data]]Interquartile range for a time slice of a random process:
InterquartileRange[PoissonProcess[3][6]]Applications (6)
InterquartileRange indicates the spread of values:
dists = {NormalDistribution[0, 1], NormalDistribution[0, 2], NormalDistribution[0, 4]};Table[Plot[PDF[𝒟, x], {x, -10, 10}, Filling -> Axis, Ticks -> {Automatic, None}, PlotRange -> {Automatic, {0, 0.4}}, PlotLabel -> N@InterquartileRange[𝒟]], {𝒟, dists}]InterquartileRange can be used as a check for agreement between data and a distribution:
𝒟 = KumaraswamyDistribution[2, 3];data = RandomVariate[𝒟, 10 ^ 3];Find the interquartile range of the data:
InterquartileRange[data]Compare with the interquartile range of the distribution:
InterquartileRange[𝒟]N[%]Identify periods of high volatility in stock data using an annual moving interquartile range:
data = TemporalData[«4»];smooth = MovingMap[InterquartileRange, data, {Quantity[365, "Day"]}];DateListPlot[smooth]Find the interquartile ranges for the girth, height, and volume of timber, respectively, in 31 felled black cherry trees:
data = ExampleData[{"Statistics", "BlackCherryTrees"}];Length[data]ListLinePlot[Transpose[data], PlotLegends -> {"Girth", "Height", "Volume"}]TableForm[{InterquartileRange[data]}, TableHeadings -> {{"Interquartile Range"}, {"Girth", "Height", "Volume"}}]Compute InterquartileRange for slices of a collection of paths of a random process:
data = RandomFunction[WienerProcess[], {0, 1, .01}, 10 ^ 3];times = Range[0, 1, .1];range = Map[{#, InterquartileRange[data[#]]}&, times];Plot of the interquartile range for the selected times:
ListPlot[range]Find the interquartile range 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](ir = InterquartileRange[heights])//NPlot the interquartile range respective of the median:
m = Median[heights];
n = Length[heights];
ListPlot[{heights, {{0, m}, {n, m}}, {{0, m - ir}, {n, m - ir}}, {{0, m + ir}, {n, m + ir}}}, Filling -> {1 -> 0, 3 -> {4}}, Joined -> {False, True, True, True}, PlotStyle -> {Automatic, Automatic, Gray, Gray}, PlotLegends -> {"heights", "median", "interquartile range"}, AxesLabel -> Automatic]Properties & Relations (4)
InterquartileRange is the difference of linearly interpolated Quantile values:
data = RandomReal[10, 20];Apply[Subtract, Quantile[data, {3 / 4, 1 / 4}, {{1 / 2, 0}, {0, 1}}]]InterquartileRange[data]InterquartileRange is the difference between the first and third quartiles:
data = RandomReal[10, 20];qrs = Quartiles[data];
qrs[[3]] - qrs[[1]]InterquartileRange[data]QuartileDeviation is half the interquartile range:
data = RandomReal[10, 20];2QuartileDeviation[data]InterquartileRange[data]BoxWhiskerChart shows the interquartile range for data:
BoxWhiskerChart[RandomVariate[NormalDistribution[0, 1], 100]]Possible Issues (1)
InterquartileRange requires numeric values in data:
InterquartileRange[{a, b, c}]The symbolic closed form may exist for some distributions:
InterquartileRange[NormalDistribution[μ, σ]]Neat Examples (1)
The distribution of InterquartileRange estimates for 20, 100, and 300 samples:
InterquartileRange[ExponentialDistribution[0.9]]SmoothHistogram[Table[InterquartileRange[RandomVariate[ExponentialDistribution[0.9], {s, 1000}]], {s, {20, 100, 300}}], Filling -> Axis, PlotLegends -> {20, 100, 300}, PlotRange -> {{0, 3}, Automatic}]Tech Notes
Related Guides
History
Introduced in 2007 (6.0) | Updated in 2017 (11.1) ▪ 2023 (13.3) ▪ 2024 (14.1)
Text
Wolfram Research (2007), InterquartileRange, Wolfram Language function, https://reference.wolfram.com/language/ref/InterquartileRange.html (updated 2024).
CMS
Wolfram Language. 2007. "InterquartileRange." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/InterquartileRange.html.
APA
Wolfram Language. (2007). InterquartileRange. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/InterquartileRange.html
BibTeX
@misc{reference.wolfram_2026_interquartilerange, author="Wolfram Research", title="{InterquartileRange}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/InterquartileRange.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_interquartilerange, organization={Wolfram Research}, title={InterquartileRange}, year={2024}, url={https://reference.wolfram.com/language/ref/InterquartileRange.html}, note=[Accessed: 13-June-2026]}