# Problem to calculate the mean in version 3.4

Michel Guirguis guirguismichel at yahoo.co.uk
Fri Sep 25 08:13:00 CEST 2015

```Good morning,

I have downloaded the version 3.4 and I have a problem to calculate the mean. The software does not recognise the function mean(). I am getting the following error.

>>> mean([1, 2, 3, 4, 4])
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
mean([1, 2, 3, 4, 4])
NameError: name 'mean' is not defined

Thanks,

Michel

9.7. statistics — Mathematical statistics functions
New in version 3.4.

Source code: Lib/statistics.py

This module provides functions for calculating mathematical statistics of numeric (Real-valued) data.

NoteUnless explicitly noted otherwise, these functions support int, float, decimal.Decimal and fractions.Fraction. Behaviour with other types (whether in the numeric tower or not) is currently unsupported. Mixed types are also undefined and implementation-dependent. If your input data consists of mixed types, you may be able to use map() to ensure a consistent result, e.g. map(float,input_data).
9.7.1. Averages and measures of central location
These functions calculate an average or typical value from a population or sample.

mean()	Arithmetic mean (“average”) of data.
median()	Median (middle value) of data.
median_low()	Low median of data.
median_high()	High median of data.
median_grouped()	Median, or 50th percentile, of grouped data.
mode()	Mode (most common value) of discrete data.
These functions calculate a measure of how much the population or sample tends to deviate from the typical or average values.

pstdev()	Population standard deviation of data.
pvariance()	Population variance of data.
stdev()	Sample standard deviation of data.
variance()	Sample variance of data.
9.7.3. Function details
Note: The functions do not require the data given to them to be sorted. However, for reading convenience, most of the examples show sorted sequences.

statistics.mean(data)
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150925/f7b89661/attachment.html>
```