Python plot and using inverse Fourier transform
To plot from a file, please write in the google search bar "Newman dow.txt". Then, from the first link, please download the file 'dow.txt'.
This file contains the daily closing value for each business day from late 2006 until the end of 2010 of the Dow Jones Industrial Average, which is a measure of average prices on the US stock market.
Write a Python program to do the following:
(a) Read in the data from dow.txt and plot them on a graph.
(b) Calculate the coefficients of the discrete Fourier transform of the data using the function rfft from numpy.fft, which produces an array of 1/2 N + 1 complex numbers.
(c) Now set all but the first 10% of the elements of this array to zero (i.e., set the last 90% to zero but keep the values of the first 10%).
(d) Calculate the inverse Fourier transform of the resulting array, zeros and all, using the function irfft, and plot it on the same graph as the original data. You may need to vary the colors of the two curves to make sure they both show up on the graph.
Comment on what you see. What is happening when you set the Fourier coefficients to zero?
(e) Now repeat but setting all but the first 2% of the coefficients to zero, and plot the resulting curve after the inverse FFT in comparison to the previous two curves. Comment again on what has changed.