I realize that this seems redundant, but I'm getting consistently better results when performing machine learning techniques that use spectral features extracted using the moving average process below, rather than using STFT results alone. I'm a machine learning guy by trade, and I don't have a background in signal processing. I'm hoping you guys might be able to guide me in the right direction here.

STFT process: I use a 10 second STFT window with 9 second overlap. The result is 1 second spaced observations that contain 10 seconds of information.

STFT Moving Average process: I use a 2.5 second STFT window with a 1/480 second increment (480Hz sample rate), then take a 10 second moving average with a 1 second increment. The result is 1 second spaced observations that contain 12.5 seconds of information.

My reasoning for using the moving average process was that I get a smoother signal to work with, but I'm not sure that it makes sense to signal processing folks. Is there anything fundamentally wrong with doing things this way besides having to deal with the additional computational cost?

edit: It seems like the reason for the improved results is related to the theory behind using Welch's method for power estimation. Maybe?

  • 2
    $\begingroup$ applying a moving average to the magnitude or magnitude-squared of the STFT is not uncommon. applying it to the complex STFT results would work only if you applied the correct linear phase compensation to each STFT frame. are you applying it to the magnitude or magnitude-squared? $\endgroup$ Sep 7, 2015 at 15:50
  • $\begingroup$ I'm applying it to the magnitude-squared. $\endgroup$
    – user17290
    Sep 7, 2015 at 16:09
  • $\begingroup$ Welcome to DSP.SE! Good question. Please reply to comments as comments; the system should allow you to comment on your own question (?). If it doesn't edit your question to respond to comments. Added comments as an answer is a Bad Thing$^\mbox{TM}$. $\endgroup$
    – Peter K.
    Sep 7, 2015 at 17:50

1 Answer 1


As rb-j says in his comment, this is often how the (magnitude-squared) STFT is smoothed $-$ using a moving average window.

The only concern might be that you're using too much smoothing. A 10 second moving average window (resulting in a 12.5 second "effective" window) may mean that some artifacts take a while to show or do not show up at all.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.