- See Also
-
Related Guides
- Descriptive Statistics
- Random Processes
- GPU Computing
- Time Series Processing
- Reliability
- Arithmetic Functions
- Spatial Point Collections
- GPU Computing with NVIDIA
- GPU Computing with Apple
- Tabular Processing Overview
- Statistical Data Analysis
- Event Series Processing
- Tabular Modeling
- Probability & Statistics with Quantities
- Precollege Education
- Computation with Structured Datasets
- Math & Counting Operations on Lists
- Date & Time
- Numerical Data
- Scientific Data Analysis
- Statistical Moments and Generating Functions
- Discrete & Integer Data
- Image Processing & Analysis
- Numbers with Uncertainty
- Spatial Statistics
- Using the Wolfram Data Drop
- Probability & Statistics
- Tabular Transformation
- Signal Visualization & Analysis
- Survival Analysis
- Audio Processing
- Symbolic Vectors, Matrices and Arrays
- GPU Programming
- Tech Notes
-
- See Also
-
Related Guides
- Descriptive Statistics
- Random Processes
- GPU Computing
- Time Series Processing
- Reliability
- Arithmetic Functions
- Spatial Point Collections
- GPU Computing with NVIDIA
- GPU Computing with Apple
- Tabular Processing Overview
- Statistical Data Analysis
- Event Series Processing
- Tabular Modeling
- Probability & Statistics with Quantities
- Precollege Education
- Computation with Structured Datasets
- Math & Counting Operations on Lists
- Date & Time
- Numerical Data
- Scientific Data Analysis
- Statistical Moments and Generating Functions
- Discrete & Integer Data
- Image Processing & Analysis
- Numbers with Uncertainty
- Spatial Statistics
- Using the Wolfram Data Drop
- Probability & Statistics
- Tabular Transformation
- Signal Visualization & Analysis
- Survival Analysis
- Audio Processing
- Symbolic Vectors, Matrices and Arrays
- GPU Programming
- Tech Notes
Mean
Details
- Mean is also known as an expectation or average.
- Mean is a location measure for data or distributions.
- For VectorQ data
, the mean estimate
is given by
. - For MatrixQ data, the mean estimate
is computed for each column vector with Mean[{{x1,y1,…},{x2,y2,…},…}] equivalent to {Mean[{x1,x2,…}],Mean[{y1,y2,…}],…}. » - For ArrayQ data, the mean estimate is equivalent to ArrayReduce[Mean,data,1]. »
- For WeightedData[{x1,x2,…},{w1,w2,…}], the mean estimate is given by
. » - Mean handles both numerical and symbolic data.
- The data can have the following additional forms and interpretations:
-
Association the values (the keys are ignored) » WeightedData weighted mean, 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 channels values or grayscale intensity value » Audio amplitude values of all channels » DateObject,TimeObject list of dates or list of times » - For a list of dates
, the mean is given by
, which is date
plus sum of durations
. - For a univariate distribution dist, the mean is given by μ=Expectation[x,xdist]. »
- For multivariate distribution dist, the mean is given by {μx ,μy,…}=Expectation[{x,y,…},{x,y,…}dist]. »
- For a random process proc, the mean function can be computed for slice distribution at time t, SliceDistribution[proc,t], as μ[t]=Mean[SliceDistribution[proc,t]]. »
Examples
open all close allBasic Examples (5)
Mean[{1.21, 3.4, 2.15, 4, 1.55}]Mean[{a, b, c, d}]Means of elements in each column:
Mean[{{a, u}, {b, v}, {c, w}}]RandomDate[4]Mean[%]Mean of a parametric distribution:
Mean[LogNormalDistribution[μ, σ]]Scope (22)
Basic Uses (6)
Exact input yields exact output:
Mean[{1, 2, 3, 4}]Mean[{π, E, 2}]Approximate input yields approximate output:
Mean[{1., 2., 3., 4.}]Mean[N[{1, 2, 3, 4}, 30]]Find the mean of WeightedData:
Mean[WeightedData[{1, 2, 3}, {Subscript[w, 1], Subscript[w, 2], Subscript[w, 3]}]]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};Mean[WeightedData[data, weights]]Find the mean of EventData:
e = {1.0, 2.1, 3.2, 4.5, 5.7};
ci = {0, 0, 0, 1, 0};Mean[EventData[e, ci]]Find the mean of a TimeSeries:
v = {3, 8, 4, 11, 9, 2};
t = {1, 3, 5, 7, 8, 10};
ts = TimeSeries[v, {t}];Mean[ts]//NThe mean depends only on the values:
Mean[ts["Values"]]//NMean[WeightedData[ts]]//NFind the mean of data involving quantities:
data = Quantity[RandomReal[1, 6], "Meters"]Mean[data]Array Data (5)
Mean for a matrix gives columnwise means:
Mean[Array[Subscript[a, ##]&, {2, 2}]]Mean for a arrays gives columnwise means at the first level:
Mean[Array[Subscript[a, ##]&, {2, 2, 2}]]Mean[RandomReal[1, 10 ^ 7]]Mean[RandomReal[1, {10 ^ 6, 5}]]When the input is an Association, Mean works on its values:
mat = RandomReal[1, {2, 2}];
assoc = AssociationThread[Range[2], mat]Mean[assoc]SparseArray data can be used just like dense arrays:
Mean[SparseArray[{{1} -> 1, {100} -> 1}]]Mean[SparseArray[{{1, 1} -> 1, {2, 2} -> 2, {3, 3} -> 3, {1, 3} -> 4}]]sp = SparseArray[{{i_, i_} :> i, {i_, j_} /; j == i + 1 :> i - 1}, {100, 10}]Mean[sp]Find mean of a QuantityArray:
data = QuantityArray[RandomReal[1, 6], "Pounds"]Mean[data]Image and Audio Data (2)
Channel-wise mean value of an RGB image:
Mean[[image]]RGBColor[%]Mean intensity value of a grayscale image:
Mean[[image]]On audio objects, Mean works channel-wise:
a = ExampleData[{"Audio", "Bee"}]AudioMeasurements[a, "Channels"]Mean[a]Date and Time (4)
dates = WolframLanguageData[All, "DateIntroduced"];DateHistogram[dates]Mean[dates]Compute the weighted mean of dates:
dates = RandomDate[4]weights = {1, 1, 1, 3};Mean[WeightedData[dates, weights]]Compute the mean 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"]}TimelinePlot[dates, ImageSize -> Medium]The mean is given in one of the input calendars:
Mean[dates]%["CalendarType"]RandomTime[3]Mean[%]List of times with different time zone specifications:
{TimeObject[{12}, TimeZone -> 0], TimeObject[{12}, TimeZone -> 2], TimeObject[{12}, TimeZone -> "Asia/Tokyo"]}Mean[%]DateValue[%, "TimeZone"]Distributions and Processes (5)
Find the mean for univariate distributions:
Mean[BinomialDistribution[n, p]]Mean[NormalDistribution[μ, σ]]Mean[MultivariateHypergeometricDistribution[n, {Subscript[m, 1], Subscript[m, 2]}]]Mean[BinormalDistribution[{Subscript[μ, 1], Subscript[μ, 2]}, {σ1, σ2}, ρ]]Mean for derived distributions:
Mean[TransformedDistribution[x^2, xNormalDistribution[μ, σ]]]Mean[ProbabilityDistribution[Sqrt[2] / π / (1 + (x - 2)^4), {x, -∞, ∞}]]data = RandomVariate[NormalDistribution[], 10 ^ 3];Mean[HistogramDistribution[data]]Mean for distributions with quantities:
Mean[QuantityDistribution[MaxwellDistribution[σ], "Meters" / "Seconds"]]Mean[QuantityDistribution[BinormalDistribution[{190, 72}, {10, 5}, 1 / 2], {"Pounds", "Inches"}]]Mean[SmoothKernelDistribution[QuantityArray[ExampleData[{"Statistics", "OldFaithful"}], {"Seconds", "Minutes"}]]]Mean function for a continuous-time random and discrete-state process:
Mean[QueueingProcess[λ, μ, ∞][t]]Plot[Evaluate[% /. {μ -> 3, λ -> 2}], {t, 0, 4}, PlotRange -> All]Find the mean of TemporalData at some time t=0.5:
td = RandomFunction[WienerProcess[1, 1], {0, 10, 0.05}, 100]Mean[td[0.5]]Find the mean function together with all the simulations:
Show[ListLinePlot[td, PlotStyle -> Directive[GrayLevel[0.75, .5], Thin]], Plot[Mean[td[t]], {t, 0, 10}, PlotStyle -> Thick]]Applications (11)
Basic Applications (5)
The mean represents the center of mass for a distribution:
dists = {NormalDistribution[3, 1], WeibullDistribution[2, 2]};Table[With[{m = Mean[𝒟]}, Plot[PDF[𝒟, x], {x, 0, 6}, Filling -> Axis, Epilog -> {Directive[Red, Dashed, Thick], Line[{{m, 0}, {m, PDF[𝒟, m]}}]}]], {𝒟, dists}]The mean for distributions without a single mode:
dists = {ExponentialDistribution[1], MixtureDistribution[{2, 1}, {NormalDistribution[2, 1], NormalDistribution[5, 1 / 2]}]};Table[With[{m = Mean[𝒟]}, Plot[PDF[𝒟, x], {x, 0, 6}, Filling -> Axis, Epilog -> {Directive[Red, Dashed, Thick], Line[{{m, 0}, {m, PDF[𝒟, m]}}]}]], {𝒟, dists}]The mean for multivariate distributions:
dists = {BinormalDistribution[{1 / 2, 1 / 2}, {0.2, 0.2}, 1 / 2], DirichletDistribution[{2, 3, 2}]};Table[{mx, my} = Mean[𝒟];Show[Plot3D[PDF[𝒟, {x, y}], {x, 0, 1}, {y, 0, 1}, Filling -> Axis, PlotStyle -> Opacity[0.5], Mesh -> None, PlotRange -> All], Graphics3D[{Red, Tube[{{mx, my, 0}, {mx, my, PDF[𝒟, {mx, my}]}}, 0.01]}]], {𝒟, dists}]Mean values of cells in a sequence of steps of 2D cellular automaton evolution:
ArrayPlot[Mean[CellularAutomaton[{14, {2, 1}, {1, 1}}, {{{1}}, 0}, 30]]]Compute means for slices of a collection of paths of a random process:
data = RandomFunction[WienerProcess[1, 1], {0, 1, .02}, 10 ^ 3];times = Range[0, 1, .1];m = Map[{#, Mean[data[#]]}&, times];Show[ListPlot[data, PlotStyle -> Directive[Thin, Opacity[.1]]], ListLinePlot[m, PlotStyle -> Green]]Applications (6)
Find the mean height for the children in a class:
heights = {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};ListPlot[heights, Filling -> Axis](m = Mean[heights])//NListPlot[{heights, {{0, m}, {25, m}}}, Joined -> {False, True}, Filling -> Axis]Find the mean height 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](m = Mean[heights])//NListPlot[{heights, {{0, m}, {25, m}}}, Joined -> {False, True}, Filling -> Axis, AxesLabel -> Automatic]Find the mean strength for 480 samples of ceramic material:
data = ExampleData[{"Statistics", "CeramicStrength"}];Length[data]m = Mean[data]Plot a Histogram for the data with mean position highlighted:
highlightbar[{{x0_, x1_}, {y0_, y1_}}, d_, meta___] := {If[x0 ≤ First[meta] < x1, Red, {}], Rectangle[{x0, y0}, {x1, y1}]}Histogram[data -> m, ChartElementFunction -> highlightbar]Compute the probability that the strength exceeds the mean:
NProbability[x > m, xdata]Compute the mean lifetime for a quantity subject to exponential decay with rate
:
MeanLifeTime = Mean[ExponentialDistribution[λ]]Smooth an irregularly spaced time series by computing a moving mean:
data = TemporalData[TimeSeries, {{{26.27, 24.26, 23.94, 23.08, 24.17, 23.99, 23.27, 24.09, 22.78, 21.51,
21.68, 21.74, 20.97, 18.74, 18.27, 17.52, 17.52, 17.73, 17.81, 18.24, 18.02, 17.74, 17.43,
16.44, 16.34, 16.91, 17.44, 16.82, 17.44, 17.18, ... 200, 3628281600,
3628368000, 3628540800, 3628800000, 3628886400, 3628972800, 3629145600}}}, 1,
{"Continuous", 1}, {"Discrete", 1}, 1, {ValueDimensions -> 1,
ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 10.1];med = MovingMap[Mean, data, {Quantity[90, "Day"]}];Show[DateListPlot[data, PlotStyle -> GrayLevel[.7]], DateListPlot[med, Joined -> True, PlotStyle -> Thick]]A vacuum system in a small electron accelerator contains 20 vacuum bulbs arranged in a circle. The vacuum system fails if at least 3 adjacent vacuum bulbs fail:
n = 20;k = 3;bexpr = And@@Map[Or@@#&, Partition[Array[Subscript[x, #]&, n], k, 1, {-1, -1}]];dists = Array[{Subscript[x, #], ExponentialDistribution[1]}&, n];ℛ = ReliabilityDistribution[bexpr, dists];Plot[SurvivalFunction[ℛ, t]//Evaluate, {t, 0, 1}]Compute the mean time to failure:
Mean[ℛ]//NProperties & Relations (17)
Mean is Total divided by Length:
Mean[{a, b, c, d}]Total[{a, b, c, d}] / Length[{a, b, c, d}]Mean is equivalent to a 1‐norm divided by Length for positive values:
data = RandomReal[10, 10];Norm[data, 1] / Length[data]Mean[data]Mean of WeightedData is equivalent to the mean of the EmpiricalDistribution of the data:
wdata = WeightedData[RandomReal[10, 100], RandomReal[1, 100]]Mean[wdata]dist = EmpiricalDistribution[wdata]Mean[dist]Mean of EventData is equivalent to the mean of the SurvivalDistribution of the data:
edata = EventData[{8, 22, 6, 4, 12, 11, 2, 34, 25, 15, 8, 6, 34, 6, 32, 1, 15, 9, 9, 6}, {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0}]Mean[edata]dist = SurvivalDistribution[edata]Mean[dist]For nearly symmetric samples, Mean and Median are nearly the same:
Mean[{1, 2, 3, 4, 4, 3, 1, 1}]//NMedian[{1, 2, 3, 4, 4, 3, 1, 1}]//Ndata = RandomReal[100, 10 ^ 6];Mean[data]Median[data]The Mean of absolute deviations from the Mean is MeanDeviation:
data = RandomReal[10, 10];MeanDeviation[data]Mean[Abs[data - Mean[data]]]Mean is logarithmically related to GeometricMean for positive values:
Log[GeometricMean[{a, b, c, d}]]//PowerExpandMean[Log[{a, b, c, d}]]Mean is the inverse of HarmonicMean of the inverse of the data:
data = RandomReal[10, 10];1 / HarmonicMean[1 / data]Mean[data]The square root of Mean of the data squared is RootMeanSquare:
data = RandomReal[10, 10];RootMeanSquare[data] == Sqrt[Mean[data ^ 2]]The n
CentralMoment is the Mean of deviations raised to the n
power:
CentralMoment[{a, b, c}, n]Mean[({a, b, c} - Mean[{a, b, c}]) ^ n]Variance is a scaled Mean of squared deviations from the Mean:
data = RandomReal[5, 20];Variance[data]Mean[(data - Mean[data]) ^ 2] Length[data] / (Length[data] - 1)Expectation for a list is a Mean:
Expectation[f[x], xRange[5]]Mean[Map[f, Range[5]]]MovingAverage is a sequence of means:
MovingAverage[{a, b, c, d, e, f}, 3]Table[Mean[Take[{a, b, c, d, e, f}, {i, i + 2}]], {i, 4}]A 0% TrimmedMean is the same as Mean:
TrimmedMean[Range[10], 0]Mean[Range[10]]The Expectation of a random variable in a distribution is the Mean:
Expectation[x, xBetaDistribution[α, β]]Mean[BetaDistribution[α, β]]LocationTest tests whether the mean is close to 0:
data = RandomVariate[NormalDistribution[0, 1], 100];Mean[data]LocationTest[data, 0]LocationTest[data, 0, "TestConclusion"]LocationEquivalenceTest tests for equivalence of means in two or more datasets:
data1 = RandomVariate[NormalDistribution[.2, .1], 100];
data2 = RandomVariate[NormalDistribution[0, .1], 100];{Mean[data1], Mean[data2]}LocationEquivalenceTest[{data1, data2}]LocationEquivalenceTest[{data1, data2}, "TestConclusion"]Possible Issues (2)
Outliers can have a disproportionate effect on Mean:
Mean[{-100, 1, 1, 1, 1, 20}]//NUse TrimmedMean to ignore a fraction of the smallest and largest elements:
TrimmedMean[{-100, 1, 1, 1, 1, 20}, 0.2]Use Median as something much less sensitive to outliers:
Median[{-100, 1, 1, 1, 1, 20}]Mean does not handle Missing directly:
data = {1.21, 3.4, 2.15, Missing[], 1.55};
Mean[data]Convert data to a TabularColumn to use the non-missing values for computation:
Mean[TabularColumn[data]]Use Query:
Query[Mean][data]Neat Examples (1)
The distribution of Mean estimates for 10, 100, and 300 samples:
SmoothHistogram[Table[Mean[RandomVariate[ExponentialDistribution[1], {s, 1000}]], {s, {10, 100, 300}}], Filling -> Axis, PlotLegends -> {10, 100, 300}, PlotRange -> {{0.2, 1.8}, Automatic}]Tech Notes
Related Guides
-
▪
- Descriptive Statistics ▪
- Random Processes ▪
- GPU Computing ▪
- Time Series Processing ▪
- Reliability ▪
- Arithmetic Functions ▪
- Spatial Point Collections ▪
- GPU Computing with NVIDIA ▪
- GPU Computing with Apple ▪
- Tabular Processing Overview ▪
- Statistical Data Analysis ▪
- Event Series Processing ▪
- Tabular Modeling ▪
- Probability & Statistics with Quantities ▪
- Precollege Education ▪
- Computation with Structured Datasets ▪
- Math & Counting Operations on Lists ▪
- Date & Time ▪
- Numerical Data ▪
- Scientific Data Analysis ▪
- Statistical Moments and Generating Functions ▪
- Discrete & Integer Data ▪
- Image Processing & Analysis ▪
- Numbers with Uncertainty ▪
- Spatial Statistics ▪
- Using the Wolfram Data Drop ▪
- Probability & Statistics ▪
- Tabular Transformation ▪
- Signal Visualization & Analysis ▪
- Survival Analysis ▪
- Audio Processing ▪
- Symbolic Vectors, Matrices and Arrays ▪
- GPU Programming
History
Introduced in 2003 (5.0) | Updated in 2014 (10.0) ▪ 2023 (13.3) ▪ 2024 (14.1)
Text
Wolfram Research (2003), Mean, Wolfram Language function, https://reference.wolfram.com/language/ref/Mean.html (updated 2024).
CMS
Wolfram Language. 2003. "Mean." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/Mean.html.
APA
Wolfram Language. (2003). Mean. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Mean.html
BibTeX
@misc{reference.wolfram_2026_mean, author="Wolfram Research", title="{Mean}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Mean.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_mean, organization={Wolfram Research}, title={Mean}, year={2024}, url={https://reference.wolfram.com/language/ref/Mean.html}, note=[Accessed: 13-June-2026]}