mean
Computes the arithmetic mean of all elements in a container or in a sequence. The elements may be numbers, vectors, or matrices.
Syntax

mean(X)

X
is a vector, matrix, list, or set


mean(expr, var, a, b)

expr
is an expression in one variablevar

var
is the variable inexpr

a
is the lower bound 
b
is the upper bound

Description
In general, mean(X) = sum(X) / #X
.
Summing a container
If X
is a nonempty container, then mean(X)
is the arithmetic mean of all elements in X
.
The following container types are supported:

vectors

the result is the mean of all components


matrices

the result is the mean of all entries


lists containing numbers

the result is the mean of all numbers


lists containing vectors

the result is the vector mean of all vectors


lists containing matrices

the result is the matrix mean of all matrices


sets containing numbers

the result is the mean of all numbers


sets containing vectors

the result is the vector mean of all vectors


sets containing matrices

the result is the matrix mean of all matrices

Typewise, the summands may be either real or complex, and the result is complex iff at least one of the summands is complex.
Summing a sequence
mean(expr, var, a, b)
computes the arithmetic mean of the expression expr
in one variable var
as var
takes all integer values from a
to b
(inclusively).
expr
must return a number, a vector, or a matrix.
Notes
These note apply to both modes of operation: summing a container and summing a sequence.
When summing a collection of objects, the objects must be of the same kind (numbers, vectors, or matrices). If they are vectors or matrices, they must all be of the same dimension or size, respectively.
Examples
Summing a container
mean(❨5, 1, 0, 10, 25, 32❩)
12.1666666667 (=73/6)
mean(IdentityMatrix(10))
0.1 (=1/10)
N ≔ 1000; mean(compute(❨cos(2⋅π⋅t/N), sin(2⋅π⋅t/N), t/N❩, t, 0, N − 1))
⎛9.05850915112⋅10^−20⎞ e⎜1.68830607047⋅10^−20⎟ ⎝ 0.4995 ⎠
Summing a sequence
N ≔ 1000; mean(❨cos(2⋅π⋅t/N), sin(2⋅π⋅t/N), t/N❩, t, 0, N − 1)
⎛9.05850915112⋅10^−20⎞ e⎜1.68830607047⋅10^−20⎟ ⎝ 0.4995 ⎠
See also

average, ArithmeticMean (synonyms)