diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py index 5c3a80ab6..51b847cc6 100644 --- a/lnst/Common/Utils.py +++ b/lnst/Common/Utils.py @@ -22,6 +22,7 @@ import ast import collections import math +import statistics import itertools from collections.abc import Iterable, Callable from contextlib import AbstractContextManager @@ -287,10 +288,9 @@ def dict_to_dot(original_dict, prefix=""): return return_list def std_deviation(values): - if len(values) <= 0: + if len(values) <= 1: return 0.0 - avg = sum(values) / float(len(values)) - return math.sqrt(sum([(float(i) - avg)**2 for i in values])/len(values)) + return statistics.stdev(values) def deprecated(func): """