def std(self): """Standard deviation of binned data""" vals = array(sortedDictValues(self.bins)) a = self.midpoints*vals sum_bin_vals = sum(self.bins.values()) mean_val = sum(a) / sum_bin_vals return sqrt(sum(((self.midpoints-mean_val)*vals)**2) / sum_bin_vals)
def mean(self): """Mean of binned data""" a = self.midpoints*array(sortedDictValues(self.bins)) return sum(a) / sum(self.bins.values())
def values(self): return sortedDictValues(self.bins)