def mean(data):
    """Return the sample arithmetic mean of data."""
n = len(data)
if n < 1:
    raise ValueError('mean requires at least one data point')
return sum(data) / n

def _ss(data):
    """Return sum of square deviations of sequence data."""
c = mean(data)
ss = sum((x - c) ** 2 for x in data)
return ss

def pstdev(data):
    """Calculates the population standard deviation."""
n = len(data)
if n < 2:
    raise ValueError('variance requires at least two data points')
ss = _ss(data)
pvar = ss / n
return pvar ** 0.5
Стандартное отклонение списка