Python: Statistics
use the bundled lib for statistics. https://docs.python.org/3/library/statistics.html
from statistics import * from math import factorial, sqrt xdata = [9, 7, 2, 3.2, 808] def xah_mean(xlist): """arithmetic mean""" return sum(xlist)/len(xlist) def xah_pstdev(xlist): """population standard deviation""" mm = mean(xlist) return sqrt(sum([(x - mm) **2 for x in xlist])/len(xlist) ) def xah_stdev(xlist): """sample standard deviation""" mm = mean(xlist) return sqrt(sum([(x - mm) **2 for x in xlist])/(len(xlist) -1) ) print( "arithmetic mean is", mean(xdata), fmean(xdata) , xah_mean(xdata)) print( "population standard deviation", pstdev(xdata), xah_pstdev(xdata)) print( "sample standard deviation", stdev(xdata), xah_stdev(xdata))