def stSpectralEntropy(X, numOfShortBlocks=10):
 L = len(X)
 Eol = numpy.sum((X ** 2))
 subWinLength = int(numpy.floor((L / numOfShortBlocks)))
 if (L != (subWinLength * numOfShortBlocks)):
  X = X[0:(subWinLength * numOfShortBlocks)]
 subWindows = X.reshape(subWinLength, numOfShortBlocks, order='F').copy()
 s = (numpy.sum((subWindows ** 2), axis=0) / (Eol + eps))
 En = (- numpy.sum((s * numpy.log2((s + eps)))))
 return En

def stSpectralEntropy ( X , numOfShortBlocks = 10 ) : L = len ( X ) Eol = numpy . sum ( ( X ** 2 ) ) subWinLength = int ( numpy . floor ( ( L / numOfShortBlocks ) ) ) if ( L != ( subWinLength * numOfShortBlocks ) ) : X = X [ 0 : ( subWinLength * numOfShortBlocks ) ] subWindows = X . reshape ( subWinLength , numOfShortBlocks , order = 'F' ) . copy ( ) s = ( numpy . sum ( ( subWindows ** 2 ) , axis = 0 ) / ( Eol + eps ) ) En = ( - numpy . sum ( ( s * numpy . log2 ( ( s + eps ) ) ) ) ) return En
computes the spectral entropy .