code: def stSpectralCentroidAndSpread(X, fs):
      
      ind = (numpy.arange(1, len(X) + 1)) * (fs/(2.0 * len(X)))
  
      Xt = X.copy()
      Xt = Xt / Xt.max()
      NUM = numpy.sum(ind * Xt)
      DEN = numpy.sum(Xt) + eps
  
      # Centroid:
      C = (NUM / DEN)
  
      # Spread:
      S = numpy.sqrt(numpy.sum(((ind - C) ** 2) * Xt) / DEN)
  
      # Normalize:
      C = C / (fs / 2.0)
      S = S / (fs / 2.0)
  
      return (C, S)
docs: Computes spectral centroid of frame (given abs(FFT))