Return the sample arithmetic mean of data, a sequence or iterator of real-valued numbers.

The arithmetic mean is the sum of the data divided by the number of data points. It is commonly called “the average”, although it is only one of many different mathematical averages. It is a measure of the central location of the data.

If data is empty, StatisticsError will be raised.

Some examples of use:

>>> mean ([ 1 , 2 , 3 , 4 , 4 ]) 2.8 >>> mean ([ - 1.0 , 2.5 , 3.25 , 5.75 ]) 2.625 >>> from fractions import Fraction as F >>> mean ([ F ( 3 , 7 ), F ( 1 , 21 ), F ( 5 , 3 ), F ( 1 , 3 )]) Fraction(13, 21) >>> from decimal import Decimal as D >>> mean ([ D ( "0.5" ), D ( "0.75" ), D ( "0.625" ), D ( "0.375" )]) Decimal('0.5625')