Return the sample arithmetic mean of data.

    If ``data`` is empty, StatisticsError will be raised.

def mean(data):
    """Return the sample arithmetic mean of data.

    If ``data`` is empty, StatisticsError will be raised.
    """
    if iter(data) is data:
        data = list(data)
    n = len(data)
    if n < 1:
        raise StatisticsError('mean requires at least one data point')
    return sum(data) / n