Sorry, module stat
is related to the POSIX system call stat
not statistics. Anyway standard deviation is the square root of the average squared difference from the mean. You can do that directly. Well, actually you want to compute the "sample" standard deviation which uses "Bessel's correction": not the average squared difference (dividing by the number of samples), but rather the squared difference divided by one less than the number of samples.
To put it briefly: sample standard deviation, which Python 3 calls statistics.stdev
, is just this:
math.sqrt(sum([(val - mean)**2 for val in x])/(len(x) - 1))