Moment
Details
- Moment is also known as a raw moment.
- For scalar order r and data being an array
: -
![x in TemplateBox[{Vectors, paclet:ref/Vectors}, RefLink, BaseStyle -> {3ColumnTableMod}][n] x in TemplateBox[{Vectors, paclet:ref/Vectors}, RefLink, BaseStyle -> {3ColumnTableMod}][n]](Files/Moment.en/3.png)

sum of r
powers »![x in TemplateBox[{Matrices, paclet:ref/Matrices}, RefLink, BaseStyle -> {3ColumnTableMod}][{n,m}] x in TemplateBox[{Matrices, paclet:ref/Matrices}, RefLink, BaseStyle -> {3ColumnTableMod}][{n,m}]](Files/Moment.en/5.png)

columnwise sum of r
powers »![x in TemplateBox[{Arrays, paclet:ref/Arrays}, RefLink, BaseStyle -> {3ColumnTableMod}][{n_(1),...,n_(k)}] x in TemplateBox[{Arrays, paclet:ref/Arrays}, RefLink, BaseStyle -> {3ColumnTableMod}][{n_(1),...,n_(k)}]](Files/Moment.en/7.png)

columnwise sum of r
powers » - Moment[x,r] is equivalent to ArrayReduce[Moment[#,r]&,x,1].
- For vector order {r1,…,rm} and data being array
: -
![x in TemplateBox[{Matrices, paclet:ref/Matrices}, RefLink, BaseStyle -> {3ColumnTableMod}][{n,m}] x in TemplateBox[{Matrices, paclet:ref/Matrices}, RefLink, BaseStyle -> {3ColumnTableMod}][{n,m}]](Files/Moment.en/9.png)

sum the rj
power in the j
column![x in TemplateBox[{Arrays, paclet:ref/Arrays}, RefLink, BaseStyle -> {3ColumnTableMod}][{n_(1),...,n_(k)}] x in TemplateBox[{Arrays, paclet:ref/Arrays}, RefLink, BaseStyle -> {3ColumnTableMod}][{n_(1),...,n_(k)}]](Files/Moment.en/12.png)

sum the rj
power in the j
column » - Moment[x,{r1,…,rm}] is equivalent to ArrayReduce[Moment[#,
]&,x,{{1},{2}}]. - Moment 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 » - For a distribution dist, the r
moment is given by Expectation[xr,xdist]. » - For a multivariate distribution dist, the {r1,…,rm}
moment is given by Expectation[x1r1⋯ xmrm,{x1,…,xm}dist]. » - For a random process proc, the moment function can be computed for slice distribution at time t, SliceDistribution[proc,t], as μr[t]=Moment[SliceDistribution[proc,t],r]. »
- Moment[r] can be used in functions such as MomentConvert, MomentEvaluate, etc. »
Examples
open all close allBasic Examples (2)
Moment[RandomVariate[NormalDistribution[], 10 ^ 4], 2]Moment[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}, 2]Moment[{{Subscript[x, 1, 1], Subscript[x, 1, 2]}, {Subscript[x, 2, 1], Subscript[x, 2, 2]}}, {1, 2}]Compute the second moment
of a univariate distribution:
Moment[NormalDistribution[μ, σ], 2]The moment
for a multivariate distribution:
Moment[BinormalDistribution[ρ], {2, 2}]Scope (22)
Basic Uses (6)
Exact input yields exact output:
Moment[{1, 2, 3, 4}, 2]Moment[{π, E, 2}, 1]Approximate input yields approximate output:
Moment[{1., 2., 3., 4.}, 2]Moment[N[{1, 2, 3, 4}, 30], 2]Find moments of WeightedData:
Moment[WeightedData[{1, 2, 3}, {Subscript[w, 1], Subscript[w, 2], Subscript[w, 3]}], 1]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};Moment[WeightedData[data, weights], 2]Find a moment of EventData:
e = {1.0, 2.1, 3.2, 4.5, 5.7};
ci = {0, 0, 0, 1, 0};Moment[EventData[e, ci], 1]Find a moment of TimeSeries:
Moment[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.], 2]The moment depends only on the values:
Moment[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"], 2]Find a moment for data involving quantities:
data = Quantity[RandomReal[1, 6], "Meters"]Moment[data, 2]Array Data (5)
For a matrix, Moment gives columnwise moments:
Moment[(| | |
| ----- | ----- |
| a1, 1 | a1, 2 |
| a2, 1 | a2, 2 |), 3]For an array, Moment gives columnwise moments at the first level:
Moment[Array[Subscript[a, ##]&, {2, 2, 2}], 3]//MatrixFormMultivariate Moment for an array:
Moment[Array[Subscript[a, ##]&, {2, 2, 2}], {3, 3}]//SimplifyMoment[RandomReal[1, 10 ^ 7], 2]Moment[RandomReal[1, {10 ^ 6, 5}], 2]When the input is an Association, Moment works on its values:
mat = RandomReal[1, {2, 2}];
assoc = AssociationThread[Range[2], mat]Moment[assoc, 3]SparseArray data can be used just like dense arrays:
Moment[SparseArray[{{1} -> 1, {100} -> 1}], 4]Moment[SparseArray[{{1, 1} -> 1, {2, 2} -> 2, {3, 3} -> 3, {1, 3} -> 4}], 2]Find the moment of a QuantityArray:
data = QuantityArray[RandomReal[1, 6], "Pounds"]Moment[data, 7]Image and Audio Data (2)
Channelwise moment of an RGB image:
Moment[[image], 5]RGBColor[%]Moment intensity value of a grayscale image:
CentralMoment[[image], 4]On audio objects, Moment works channelwise:
a = ExampleData[{"Audio", "Bee"}]AudioMeasurements[a, "Channels"]Moment[a, 3]Distribution and Process Moments (5)
Scalar moment for univariate distributions:
Moment[BinomialDistribution[n, p], 1]Moment[NormalDistribution[μ, σ], 2]Scalar moment for multivariate distributions:
Moment[BinormalDistribution[{Subscript[μ, 1], Subscript[μ, 2]}, {σ1, σ2}, ρ], 3]Moment[DirichletDistribution[{a, b, c}], 2]Joint moment for multivariate distributions:
Moment[MultivariateHypergeometricDistribution[n, {Subscript[m, 1], Subscript[m, 2]}], {1, 1}]Moment[BinormalDistribution[{Subscript[μ, 1], Subscript[μ, 2]}, {σ1, σ2}, ρ], {2, 1}]Compute a moment for a symbolic order r:
Moment[BetaDistribution[a, b], r]A moment may only evaluate for specific orders:
Moment[ExtremeValueDistribution[a, b], r]% /. r -> 3A moment may only evaluate numerically:
Moment[VonMisesDistribution[Pi / 2, 2], 4]N[%]Moments for derived distributions:
Moment[TransformedDistribution[x^2, xNormalDistribution[μ, σ]], 2]Moment[ProbabilityDistribution[(Sqrt[2] / π) / (1 + (x - 2)^4), {x, -∞, ∞}], 1]data = RandomVariate[NormalDistribution[], 10 ^ 3];Moment[HistogramDistribution[data], 1]Moment function for a random process:
Moment[BrownianBridgeProcess[μ, σ][t], 4]Plot[Evaluate[% /. {μ -> 3, σ -> 1}], {t, 0, 1}, PlotRange -> All]Find a moment of TemporalData at a time t=0.5:
td = RandomFunction[WienerProcess[1, 1], {0, 10, 0.05}, 100]Moment[td[0.5], 1]Find the corresponding moment function together with all the simulations:
Show[ListLinePlot[td, PlotStyle -> Directive[Opacity[0.7], Thin]], Plot[Moment[td[t], 1], {t, 0, 10}, PlotStyle -> Thick]]Formal Moments (4)
TraditionalForm formatting for formal moments:
Moment[r]//TraditionalFormMoment[{p, q, r}]//TraditionalFormConvert combinations of formal moments to an expression involving Moment:
MomentConvert[CentralMoment[2], Moment]//TraditionalFormMomentConvert[CentralMoment[2]Cumulant[2], Moment]//TraditionalFormEvaluate an expression involving formal moments μ2+μ3 for a distribution:
MomentEvaluate[Moment[2] + Moment[3], PoissonDistribution[λ]]data = RandomVariate[PoissonDistribution[1], 10^4];MomentEvaluate[Moment[2] + Moment[3], data]Find a sample estimator for an expression involving Moment:
estimator = MomentConvert[Moment[2], "UnbiasedSampleEstimator"]Evaluate the resulting estimator for data:
data = RandomVariate[PoissonDistribution[1], 10^4];MomentEvaluate[estimator, data]Applications (10)
Moments for Data and Time Series (3)
The law of large numbers states that a sample moment approaches a population moment as the sample size increases. Use Histogram to show probability distribution of a second sample moment of uniform random variates for different sample sizes:
Histogram[Table[Moment[RandomReal[1, {n, 10 ^ 3}], 2], {n, {10, 10^2, 10^3}}], 40, "ProbabilityDensity", ChartLegends -> {10, 10^2, 10^3}]Visualize the convergence process:
ListLinePlot[Accumulate[RandomReal[1, 10 ^ 4] ^ 2] / Range[10 ^ 4], PlotRange -> {0.2, 0.5}]Compute a moving moment of a time series data:
data = TemporalData[TimeSeries, {{{0., -0.024510587716402032, -0.23697150976969208, -0.12178339223049947,
0.0356898098034821, 0.136151185542904, 0.0510713902440678, 0.28475806711161716,
0.25987506162754515, 0.2754574024933936, 0.2083480628921990 ... 1538234, -0.09713966281751486, 0.005118404645412064,
0.1288920274799618}}, {{0, 1., 0.01}}, 1, {"Continuous", 1}, {"Continuous", 1}, 1,
{ValueDimensions -> 1, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False,
10.1];md = MovingMap[Moment[#, 2]&, data, .1];ListLinePlot[md, PlotRange -> All]Compute moments for slices of a collection of paths of a random process:
data = RandomFunction[WienerProcess[], {0, 1, .01}, 10 ^ 3];times = Range[0, 1, .1];m = Map[{#, Moment[data[#], 4]}&, times];Plot the fourth moments over these paths:
Show[ListPlot[data], ListLinePlot[m, PlotStyle -> Green]]Method of Moments (3)
Estimate parameters of a distribution using the method of moments:
data = RandomVariate[GammaDistribution[3, 6], 10 ^ 4];meq = Table[Moment[data, k] == Moment[GammaDistribution[α, β], k], {k, 1, 2}]NSolve[meq, {α, β}]Compare the data with the estimated parametric distribution:
Show[Histogram[data, Automatic, "PDF"], Plot[Evaluate[PDF[GammaDistribution[α, β], x] /. %], {x, 0, 100}, PlotStyle -> Thick]]Find normal approximation to GammaDistribution using the method of moments:
gdist = GammaDistribution[α, β];meq = Table[Moment[gdist, k] == Moment[NormalDistribution[μ, σ], k], {k, 1, 2}]Solve[(And@@meq)∧σ > 0, {μ, σ}, Reals]{ndist} = Refine[NormalDistribution[μ, σ] /. %, β > 0∧α > 0]Compare the original and the approximated distributions:
Plot[{PDF[gdist, x], PDF[ndist, x]} /. {α -> 13, β -> 3}, {x, 0, 80}, Evaluated -> True]Moments of PearsonDistribution satisfy a three-term recurrence equation implied by the defining differential equation for the density function
:
eq[r_] := r * Subscript[b, 0] * Moment[r - 1] + (r + 1) Subscript[b, 1] * Moment[r] + (r + 2) Subscript[b, 2] * Moment[r + 1] - Subscript[a, 1] * Moment[r + 1] - Subscript[a, 0] * Moment[r]meq = Table[eq[r], {r, 0, 3}]MomentEvaluate[meq, PearsonDistribution[Subscript[a, 1], Subscript[a, 0], Subscript[b, 2], Subscript[b, 1], Subscript[b, 0]]]//FullSimplifyUse the recurrence equation to express parameters of PearsonDistribution in terms of its moments:
dist = PearsonDistribution[Subscript[a, 1], Subscript[a, 0], Subscript[b, 2], Subscript[b, 1], Subscript[b, 0]] /. Solve[meq == 0 /. Moment[0] -> 1, {Subscript[a, 1], Subscript[a, 0], Subscript[b, 2], Subscript[b, 1], Subscript[b, 0]}][[1]];data = RandomVariate[LaplaceDistribution[1, 1], 10 ^ 5];Fit PearsonDistribution to data:
fdist = MomentEvaluate[dist, data] /. Subscript[a, 1] -> 1Show[Histogram[data, {-10, 10, 1}, "ProbabilityDensity"], Plot[PDF[fdist, x], {x, -10, 10}, PlotStyle -> Thick]]Check that moments of the resulting distribution are equal to moments of data:
MomentEvaluate[{Moment[1], Moment[2], Moment[3], Moment[4]}, fdist]MomentEvaluate[{Moment[1], Moment[2], Moment[3], Moment[4]}, data]PDF Approximations from Moments (3)
Two different distributions can have the same sequence of moments:
dist1 = ProbabilityDistribution[(1/4)Exp[-Abs[x]^1 / 2], {x, -Infinity, Infinity}];dist2 = ProbabilityDistribution[(1/4)Exp[-Abs[x]^1 / 2](1 + Cos[Sqrt[Abs[x]]]), {x, -Infinity, Infinity}];Compare their densities on log-scale:
LogPlot[{PDF[dist1, x], PDF[dist2, x]}, {x, -100, 100}, PlotRange -> All]Moment[dist1, k]Moment[dist2, k]Prove them equal for all non-negative integer orders:
FullSimplify[% == %%, k∈Integers && k ≥ 0]Build type A Gram–Charlier expansion of order 6:
data = Standardize[RandomVariate[SkewNormalDistribution[0, 1, 2], 10 ^ 5]];pdf = PDF[NormalDistribution[], z] * Sum[(Underoverscript[∑, k = 0, Floor[(r/2)]]((-1)^r - k Moment[data, r - 2 k]/(k! (r - 2 k)!) 2^k))(-(1/Sqrt[2]))^rHermiteH[r, (z/Sqrt[2])], {r, 0, 6}]Show[Histogram[data, 20, "ProbabilityDensity"], Plot[pdf, {z, -4, 4}]]A monotone PDF
with a positive domain is bounded by
:
𝒟 = ExponentialDistribution[1];Prove the identity for exponential distribution for the first few orders:
Table[Reduce[PDF[𝒟, x] > (r + 1)Moment[𝒟, r] / x ^ (r + 1) && x > 0, x, Reals], {r, 1, 5}]LogPlot[{PDF[𝒟, x], Table[(r + 1)Moment[𝒟, r] / x ^ (r + 1), {r, 5}]}//Evaluate, {x, 1, 15}, PlotStyle -> {Thick}~Join~Table[Dashed, 5]]Expectation Approximation from Moments (1)
Find quadrature rule for approximating the expectation of a function of a random variable:
𝒩 = 6;
𝒟 = PoissonDistribution[5];Find
lowest-order orthogonal polynomials:
mat = Table[Moment[𝒟, n + m], {n, 0, 𝒩}, {m, 0, 𝒩}];polys = (x ^ Range[0, 𝒩]).Inverse[CholeskyDecomposition[mat]]PadLeft[Table[NExpectation[polys[[i]] polys[[j]], x𝒟], {i, 𝒩}, {j, i, 𝒩}]]//Quiet//Choppts = x /. {ToRules[NRoots[Last[polys] == 0, x]]}Find quadrature weights, requiring rule to be exact on polynomials of order up to
:
weights = LinearSolve[Transpose@Outer[Power, pts, Range[0, 𝒩]], Table[Moment[𝒟, r], {r, 0, 𝒩}]]Compute approximation to expectation of
:
weights.(1 + pts ^ 2)^3 / 2Check with NExpectation:
NExpectation[(1 + x^2)^3 / 2, x𝒟]Properties & Relations (8)
Moment of order r is equivalent to Expectation of the power r of the random variable:
Expectation[x^4, xLogisticDistribution[0, 1]]Moment[LogisticDistribution[0, 1], 4]A multivariate moment is equivalent to Expectation of a multivariate monomial:
Expectation[x^4 y^2, {x, y}DirichletDistribution[{2, 3, 4}]]Moment[DirichletDistribution[{2, 3, 4}], {4, 2}]For univariate distributions, Moment of order one is the Mean:
Moment[NormalDistribution[μ, σ], 1] == Mean[NormalDistribution[μ, σ]]Moment[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}, 1] == Mean[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5]}]Mean of a multivariate distribution is a list of moments of its univariate marginal distributions:
dist = BinormalDistribution[{Subscript[μ, 1], Subscript[μ, 2]}, {Subscript[σ, 1], Subscript[σ, 2]}, ρ];Mean[dist]{Mean[MarginalDistribution[dist, 1]], Mean[MarginalDistribution[dist, 2]]}Alternatively, use Moment with orders given by unit vectors:
{Moment[dist, UnitVector[2, 1]], Moment[dist, UnitVector[2, 2]]}Moment of order
is the same as
when both exist:
mgf = MomentGeneratingFunction[GammaDistribution[α, β], t]SeriesCoefficient[mgf, {t, 0, r}, Assumptions -> α > 0 && r ≥ 0]r!Use Moment directly:
Moment[GammaDistribution[α, β], r]FullSimplify[FunctionExpand[% == %%], α > 0∧β > 0∧r∈Integers∧r ≥ 0]Find the moment-generating function by using GeneratingFunction:
GeneratingFunction[Moment[RayleighDistribution[σ], r] / r!, r, t]Compare with direct evaluation of MomentGeneratingFunction:
MomentGeneratingFunction[RayleighDistribution[σ], t]Simplify[% == %%, σ > 0 && Im[t] == 0]Moment can be expressed through CentralMoment, Cumulant or FactorialMoment:
MomentConvert[Moment[4], CentralMoment]MomentConvert[Moment[3], Cumulant]MomentConvert[Moment[6], FactorialMoment]Sample moments are unbiased estimators of population moments:
est = MomentConvert[Moment[{1, 2}], "SampleEstimator"]Hence the sampling distribution expectation of the estimator equals the estimated moment:
MomentConvert[est, Moment]Verify this on a sample of fixed size; evaluate the estimator on the sample:
MomentEvaluate[est, {{Subscript[x, 1], Subscript[y, 1]}, {Subscript[x, 2], Subscript[y, 2]}, {Subscript[x, 3], Subscript[y, 3]}, {Subscript[x, 4], Subscript[y, 4]}, {Subscript[x, 5], Subscript[y, 5]}}]Find its expectation assuming independent identically distributed random variables
and
:
% /. (Subscript[x, i_] ^ n_. Subscript[y, j_] ^ m_.) :> Moment[{n, m}]The multivariate moment of an array of depth
has depth
:
arr = Array[Subscript[a, Row@{##}]&, {n = 4, m = 3, 2, 3}];
rs = {2, 2, 2};
Length[rs] == mMoment[arr, rs] ==
ArrayReduce[Mean,
ArrayReduce[Times@@Power[#, rs]&, arr, 2],
1]//SimplifyPossible Issues (2)
Heavy-tailed distributions may only have a few low-order moments defined:
Moment[StudentTDistribution[5], r]Some heavy-tailed distributions have no moments defined:
Moment[CauchyDistribution[0, 1], r]Often, quantiles can be used to characterize distributions:
Quantile[CauchyDistribution[0, 1], p]Neat Examples (2)
Find an unbiased estimator for a product of moments:
(est = MomentConvert[Moment[1]Moment[2]Moment[3], {"UnbiasedEstimator", n}, "PowerSymmetricPolynomial"])//TraditionalFormCheck unbiasedness for a special case of
on a GammaDistribution:
𝒟 = GammaDistribution[α, β];
MomentEvaluate[est /. n -> 4, {x1, x2, x3, x4}]Expectation[%, {x1, x2, x3, x4}ProductDistribution[{𝒟, 4}]]% == MomentEvaluate[Moment[1]Moment[2]Moment[3], 𝒟]The distribution of Moment estimates for 20, 100 and 300 samples:
Moment[ExponentialDistribution[0.9], 2]SmoothHistogram[Table[Moment[RandomVariate[ExponentialDistribution[0.9], {s, 1000}], 2], {s, {20, 100, 300}}], Filling -> Axis, PlotLegends -> {20, 100, 300}, PlotRange -> {{0, 5}, Automatic}]History
Introduced in 2010 (8.0) | Updated in 2024 (14.0)
Text
Wolfram Research (2010), Moment, Wolfram Language function, https://reference.wolfram.com/language/ref/Moment.html (updated 2024).
CMS
Wolfram Language. 2010. "Moment." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/Moment.html.
APA
Wolfram Language. (2010). Moment. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Moment.html
BibTeX
@misc{reference.wolfram_2026_moment, author="Wolfram Research", title="{Moment}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Moment.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_moment, organization={Wolfram Research}, title={Moment}, year={2024}, url={https://reference.wolfram.com/language/ref/Moment.html}, note=[Accessed: 12-June-2026]}