Previous Up Next

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.

Examples

mean([1,2,3,4])
     
5
2
          

since (1+2+3+4)/4=5/2.

mean([[1,2,3],[5,6,7]])
     

3,4,5
          

since (1+5)/2=3, (2+6)/2=4 and (3+7)/2=5.

mean([2,4,6,8],[2,2,3,3])
     
27
5
          

since (2· 2+4· 2+6· 3+8· 3)/(2+2+3+3)= 27/5.

mean([[1,2],[3,4]],[[1,2],[2,1]])
     



7
3
,
8
3



          

since (1· 1+3· 2)/(1+2)=7/3 and (2· 2+4· 1)/(2 + 1)=8/3.


Previous Up Next