I wanted to visualise angle and magnitude of moving average DFT. I used python3 for that:

import numpy
irs = [1 / 5] * 5
dft_irs = numpy.fft.fft(irs)
print("dft", dft_irs)
print("magnitude", numpy.absolute(dft_irs))
print("angle", numpy.angle(dft_irs))

I got results that I do not understand

dft [  1.00000000e+00+0.j   0.00000000e+00+0.j   1.38777878e-17+0.j 1.38777878e-17+0.j   0.00000000e+00+0.j]
magnitude [  1.00000000e+00   0.00000000e+00   1.38777878e-17   1.38777878e-17 0.00000000e+00]
angle [ 0.  0.  0.  0.  0.]

Here phase shift is 0 for every frequency while I know it is not for moving average filter. Please help me understand why I got this strange result.


You are looking at the frequency response at multiples of $2 \pi /5$, where the response is either 1 or 0.

If you add several 0 values to the end of irs, you'll get the frequency response at more intermediate frequencies, where you can see that phase is not zero.

  • $\begingroup$ Can you please expand more at what adding zeroes to the IRS does or suggest some readings? $\endgroup$ – Trismegistos Aug 5 '17 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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