If you are familiar with basic statistics, I think you know what is Standard Deviation, if you dont know what is Standard Deviation you can check wiki for details.
And if it seems yet hard to wrap the idea into your brain,check this thread. Hope you understand it now. Standard deviation is an efficient when you want to understand a set of data and widely used in different industries. I was working with an algorithm couple of months ago where I had to calculated standard deviation of a series of data. And the sets of data is large.
After coding couple of versions I code a small python class which calculates standard deviation of data. Check it out
|from __future__ import division|
|from math import sqrt, pow|
|def do_round(self, data):|
|data = "%.3f" % round(data, 3)|
|def do_diff(self, n, mean):|
|return pow((n–mean), 2)|
|def standDev(self, data_list):|
|mean = sum(data_list)/len(data_list)|
|result = sqrt(sum([self.do_diff(s, mean) for s in \|
|data_list = [2, 4, 4, 4, 5, 5, 7, 9 ]|
|std = StandardDeviation()|