20.1.1 Mean
Recall that the mean of a list x1,…,xn is simply their numeric
average (x1+⋯+xn)/n.
The mean command finds the
mean of a list.
-
mean takes one mandatory argument and one optional
argument:
-
L, a list or matrix of numbers.
- W, a list or matrix of weights, the same size as L.
- mean(L ⟨,W⟩) returns the mean of the list or a list with
the means of the columns of the matrix.
Examples
since (1+2+3+4)/4=5/2.
since (1+5)/2=3, (2+6)/2=4 and (3+7)/2=5.
mean([2,4,6,8],[2,2,3,3]) |
since (2· 2+4· 2+6· 3+8· 3)/(2+2+3+3)=
27/5.
mean([[1,2],[3,4]],[[1,2],[2,1]]) |
since (1· 1+3· 2)/(1+2)=7/3 and (2· 2+4· 1)/(2 +
1)=8/3.