6

I can calculate RMS in frequency domain as derived from Parseval's Theorem.

But what if I have applied a windowing function before doing the FFT (in my case a Hann window)?. Now the RMS values are not correct any more. How do I calculate the correct RMS values?

endolith
  • 15,759
  • 8
  • 67
  • 118
venkibabu
  • 75
  • 1
  • 2
  • 4
  • Loss problem due to attenuation at the window edges is solved by overlap (typically 75% for Hanning window) –  Feb 11 '15 at 19:08

3 Answers3

3

For a reasonably stationary time domain signal you can assume

rms(signal*windows) = rms(signal)*rms(window)

and can estimate the RMS of the un-windowed time signal this way. For a hanning window that means calculate the RMS using Perceval and then multiply with sqrt(8/3). It's not exact but will be fairly close if the signal is stationary with respect to the window length. If it isn't stationary the interpretation of RMS isn't particularly well defined and it would helpful to learn more about your application and what exactly you are trying to do.

Hilmar
  • 9,472
  • 28
  • 35
  • Right. For a reasonably stationary TD signal. If it is not stationary, the RMS can freely vary according the part the window is discarding the most... The RMS indeed no longer has sense, and any normalization has no sense either... – Brethlosze Mar 15 '22 at 02:42
1

A window function (except the implicit rectangle function) in informationally lossy, especially of transient signals near the edge of the window, and for low frequency stationary sinusoids that are not periodic in the window. For high frequency sinusoidal content that is of constant amplitude and periodic in the aperture, the approximation of scaling magnitudes by the area of the window function is closer to accurate, but will still vary slightly with the phase of the each sinusoid.

hotpaw2
  • 35,346
  • 9
  • 47
  • 90
  • Your answer may be a bit misleading. There is no information lost when applying one of the most common used windows in the sense that the window operation can be inverted in the time-domain as well as in the frequency domain. – niaren Oct 01 '11 at 18:48
  • 2
    @niaren: In practical use assuming any quantization, more information is lost by a non-rectangular window than by constant scaling. Also some windows go to zero at one end or the other, which is complete information loss. – hotpaw2 Oct 01 '11 at 19:54
0

Half-baked answer: Hmm... Is this possible? If the waveform consists of a high frequency sine and low frequency sine alternating in time, then the time at which you happen to window it would alter the height of different parts of the frequency spectrum. Would the overall RMS value of the spectrum still be the same no matter when you window it? If so, I'd think it's just a matter of scaling by the energy of the window itself. If not, I'd say it's impossible.

Example:

n = 1000
t = linspace(0, 1, n, endpoint=False)
x = sin(2*pi*t)        * sin(2*pi*100*t)
y = sin(2*pi*t + pi/2) * sin(2*pi*100*t) # just a phase shift
print(sum(abs(x)**2))          # = 250
print(sum(abs(y)**2))          # = 250
print(sum(abs(fft(x))**2)/n)   # = 250
print(sum(abs(fft(y))**2)/n)   # = 250

w = hamming(n)
print(sum(abs(fft(x*w))**2)/sum(w**2))  # = 216
print(sum(abs(fft(y*w))**2)/sum(w**2))  # = 283

x*wy*w

So I think it's impossible.

endolith
  • 15,759
  • 8
  • 67
  • 118
  • I don't understand why in two last cases, for applied window, you scale by n. It should be sum(w**2), which gives exact match. Obviously that also holds when w=rectwin(n). – jojeck Feb 11 '15 at 21:44
  • @jojek The point is that it varies for x vs y because of the phase shift. Are you saying it should be sum(abs(fft(x*w))**2)/n*sum(w**2) to normalize for the window taper? – endolith Feb 14 '15 at 15:30
  • Not really. More like this. What do you think? – jojeck Feb 14 '15 at 17:43
  • @jojek Well your window includes multiple periods of the waveform, so it will be closer to the same thing. Try with linspace from 0 to 1 – endolith Feb 14 '15 at 19:19