]> git.parisson.com Git - timeside.git/commitdiff
Merge dev into diadems
authorThomas Fillon <thomas@parisson.com>
Thu, 19 Jun 2014 14:00:33 +0000 (16:00 +0200)
committerThomas Fillon <thomas@parisson.com>
Thu, 19 Jun 2014 14:00:33 +0000 (16:00 +0200)
1  2 
timeside/analyzer/utils.py

index bfe788c73cadc6a509b30f2ba2682ce2f70a2642,b8ad23c086f93ddce1d50e00645cabf657a77f1d..e7396240fd8c36e1a2e6ddcabf2df39b3c4f341c
@@@ -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')