From: Thomas Fillon Date: Thu, 19 Jun 2014 14:00:33 +0000 (+0200) Subject: Merge dev into diadems X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=06e4f1be51c4bad5216981ad7b24c65b0c9dc1ab;p=timeside.git Merge dev into diadems --- 06e4f1be51c4bad5216981ad7b24c65b0c9dc1ab diff --cc timeside/analyzer/utils.py index bfe788c,b8ad23c..e739624 --- a/timeside/analyzer/utils.py +++ b/timeside/analyzer/utils.py @@@ -225,9 -225,13 +225,21 @@@ def entropy(serie, nbins=10, base=np.ex return estimate +def smoothing(data, number_of_points=3, smoothing_function=np.mean): + """ + """ + + w = number_of_points/2 + return [0.0]*w + [smoothing_function(data[i-w:i+w]) for i in range(w, len(data)-w)] + [0.0]*w ++ ++ + def nextpow2(value): + """Compute the nearest power of two greater or equal to the input value""" + if value >= 1: + return 2**np.ceil(np.log2(value)).astype(int) + elif value > 0: + return 1 + elif value == 0: + return 0 + else: + raise ValueError('Value must be positive')