I want to calculate averaged power of a time-domain signal by means of its spectrum. I guess Parseval is the right tool.
So I sample a sinus of 100 Hz 10000x within one second.
Unfortunately the sum of the squared samples euqals not the sum of the FFT amplitudes (weighted by the number of FFT bins). Where is the mistake?
# Some python code import numpy import matplotlib.pyplot as plt # Create Time Domain Signal for 1 sec fs = n = 10000 # Samplingfrequency ti = numpy.linspace(0,1,num=fs) sx = 1*numpy.sin(2*numpy.pi*100*ti) # Calculate spectrum via FFT and account for scaling n/2 # taking the real fft (rfft) only the positive frequencies are calculated fx = numpy.fft.rfft(sx)/(n/2) no_of_points = fx.shape # Calculate RMS for time domains signal + spectrum parseval_sx = numpy.sum(sx**2) parseval_fx = numpy.sum(numpy.abs(fx)**2)/no_of_points print parseval_sx, " equals not ", parseval_fx
4999.5 equals not 0.000199940012002