# Taking the Moving Average of STFT Results

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?

• 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? – robert bristow-johnson Sep 7 '15 at 15:50
• I'm applying it to the magnitude-squared. – user17290 Sep 7 '15 at 16:09
• 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}$. – Peter K. Sep 7 '15 at 17:50

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