MeanDeviation[data]
gives the mean absolute deviation from the mean of the elements in data.
MeanDeviation
MeanDeviation[data]
gives the mean absolute deviation from the mean of the elements in data.
Details
- MeanDeviation is also known as MAD.
- MeanDeviation is a measure of dispersion.
- For VectorQ data
, the mean deviation
is given by
, where
is the mean of data. - For MatrixQ data, the mean deviation is computed for each column vector with MeanDeviation[{{x1,y1,…},{x2,y2,…},…}] equivalent to {MeanDeviation[{x1,x2,…}],MeanDeviation[{y1,y2,…}],…}. »
- For ArrayQ data, the mean deviation is equivalent to ArrayReduce[MeanDeviation,data,1]. »
- MeanDeviation handles both numerical and symbolic data.
- 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 »
Examples
open all close allBasic Examples (4)
MeanDeviation of a list of numbers:
MeanDeviation[{1.21, 3.4, 2, 4.66, 1.5, 5.61, 7.22}]MeanDeviation of symbolic data:
MeanDeviation[{a, b, c}]MeanDeviation of the columns of a matrix:
MeanDeviation[{{1, 2}, {4, 8}, {5, 3}, {2, 15}}]MeanDeviation of a list of dates:
MeanDeviation[{Yesterday, Today, Tomorrow}]Scope (18)
Basic Uses (6)
Exact input yields exact output:
MeanDeviation[{1, 2, 3, 7}]MeanDeviation[{π, E, 2}]//TogetherApproximate input yields approximate output:
MeanDeviation[{1., 2., 3., 7.}]MeanDeviation[N[{1, 2, 3, 7 / 11}, 30]]Find the mean deviation of WeightedData:
MeanDeviation[WeightedData[{1, 2, 3}, {Subscript[w, 1], Subscript[w, 2], Subscript[w, 3]}]]//Simplifydata = {8, 3, 5, 4, 9, 1, 4, 2, 2, 3};
weights = {0.15, 0.09, 0.12, 0.10, 0.16, 0.3, 0.11, 0.08, 0.08, 0.09};MeanDeviation[WeightedData[data, weights]]Find the mean deviation of EventData:
e = {1.0, 2.1, 3.2, 4.5, 5.7};
ci = {0, 0, 0, 1, 0};MeanDeviation[EventData[e, ci]]Find the mean deviation for TimeSeries:
MeanDeviation[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 mean deviation depends only on the values:
MeanDeviation[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 mean deviation of data involving quantities:
data = Quantity[RandomReal[1, 6], "Meters"]MeanDeviation[data]Array Data (5)
MeanDeviation for a matrix works columnwise:
MeanDeviation[Array[Subscript[a, ##]&, {2, 2}]]//SimplifyMeanDeviation for a tensor works across the first index: »
MeanDeviation[Array[Subscript[a, ##]&, {2, 2, 2}]]MeanDeviation[RandomReal[1, 10 ^ 7]]MeanDeviation[RandomReal[1, {10 ^ 6, 3}]]When the input is an Association, MeanDeviation works on its values:
mat = RandomReal[1, {2, 2}];
assoc = AssociationThread[Range[2], mat]MeanDeviation[assoc]SparseArray data can be used just like dense arrays:
MeanDeviation[SparseArray[{{1} -> 2, {2} -> 5, {3} -> 7}]]MeanDeviation[SparseArray[{{1, 1} -> 3, {2, 1} -> 4, {2, 2} -> 7}]]sp = SparseArray[{{i_, i_} :> i, {i_, j_} /; j == i + 1 :> i - 1}, {100, 10}]MeanDeviation[sp]Find mean deviation of a QuantityArray:
data = QuantityArray[RandomReal[1, 6], "Pounds"]MeanDeviation[data]Image and Audio Data (2)
Channelwise mean deviation value of an RGB image:
MeanDeviation[[image]]RGBColor[%]Mean deviation value of a grayscale image:
MeanDeviation[[image]]On audio objects, MeanDeviation works channelwise:
a = ExampleData[{"Audio", "Bee"}]AudioMeasurements[a, "Channels"]MeanDeviation[a]Date and Time (5)
Compute mean deviation of dates:
dates = WolframLanguageData[All, "DateIntroduced"];DateHistogram[dates]MeanDeviation[dates]UnitConvert[%, "Years"]Compute the weighted mean deviation of dates:
dates = RandomDate[4]weights = {1, 1, 1, 3};MeanDeviation[WeightedData[dates, weights]]Compute the mean deviation 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"]}MeanDeviation[dates]UnitConvert[%, "Years"]Compute the mean deviation of times:
times = RandomTime[3]MeanDeviation[times]Compute the mean deviation of times with different time zone specifications:
times = {TimeObject[{12}, TimeZone -> 0], TimeObject[{12}, TimeZone -> 2], TimeObject[{12}, TimeZone -> "Asia/Tokyo"]}MeanDeviation[times]Applications (3)
Identify periods of high volatility in stock data using a five-year moving mean deviation:
data = TemporalData[«4»];smooth = MovingMap[MeanDeviation, data, {Quantity[5 * 365, "Day"]}];DateListPlot[smooth]Compute mean deviations for slices of a collection of paths of a random process:
data = RandomFunction[WienerProcess[], {0, 1, .01}, 10 ^ 3];times = Range[0, 1, .1];md = Map[{#, MeanDeviation[data["SliceData", #]]}&, times];Plot mean deviations over these paths:
Show[ListPlot[data], ListLinePlot[md, PlotStyle -> Green]]Find the mean deviation 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](md = MeanDeviation[heights])//NPlot the mean deviation respective of the mean:
m = Mean[heights];
n = Length[heights];
ListPlot[{heights, {{0, m}, {n, m}}, {{0, m - md}, {n, m - md}}, {{0, m + md}, {n, m + md}}}, Filling -> {1 -> 0, 3 -> {4}}, Joined -> {False, True, True, True}, PlotStyle -> {Automatic, Automatic, Gray, Gray}, PlotLegends -> {"heights", "mean", "mean deviation bands"}, AxesLabel -> Automatic]Properties & Relations (4)
MeanDeviation is the Mean of absolute deviations from the Mean:
data = RandomReal[10, 10];Mean[Abs[data - Mean[data]]]MeanDeviation[data]MeanDeviation is equivalent to the 1‐norm of the deviations divided by the Length:
data = RandomReal[10, 10];Norm[data - Mean[data], 1] / Length[data]MeanDeviation[data]For large uniform datasets, MeanDeviation and MedianDeviation are nearly the same:
data = RandomReal[10, 10 ^ 6];MeanDeviation[data]MedianDeviation[data]MeanDeviation as a scaled ManhattanDistance from the Mean:
data = {a, b, c}mean = Table[Mean[data], {Length[data]}]MeanDeviation[data]ManhattanDistance[data, mean] / Length[data]Neat Examples (1)
Ratio of MeanDeviation to MedianDeviation for increasing sample size:
data = RandomReal[10, 10 ^ 5];ListPlot[Table[{i, MeanDeviation[Take[data, i]] / MedianDeviation[Take[data, i]]}, {i, 5000, 10 ^ 5, 5000}]]Tech Notes
Related Guides
Text
Wolfram Research (2007), MeanDeviation, Wolfram Language function, https://reference.wolfram.com/language/ref/MeanDeviation.html (updated 2024).
CMS
Wolfram Language. 2007. "MeanDeviation." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/MeanDeviation.html.
APA
Wolfram Language. (2007). MeanDeviation. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MeanDeviation.html
BibTeX
@misc{reference.wolfram_2026_meandeviation, author="Wolfram Research", title="{MeanDeviation}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/MeanDeviation.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_meandeviation, organization={Wolfram Research}, title={MeanDeviation}, year={2024}, url={https://reference.wolfram.com/language/ref/MeanDeviation.html}, note=[Accessed: 13-June-2026]}