# observe the effect of convolution (filtering) in the frequency domain N = 2048 y = runif(N,min=-.5,max=.5) # while noise (flat freq spectrum) a = c(1,1,1,1,1)/5 # our filter z = filter(y,a,method="conv",circular=T) # filter (convolve) the y with a Y = fft(y) # the freq spectrum of filtered data plot(Mod(Y[1:(N/2)])) #stopp Z = fft(z) # the freq spectrum of filtered data plot(Mod(Z[1:(N/2)])) # plot relevant values #stopp; aa = c(a,rep(0,N-length(a))) # pad filter with zeros to get # same length as y A = fft(aa) # the transform of the filter lines(20*Mod(A[1:(N/2)]),col="red") # add plot of filter transform. # note that FFT(data) x FFT(filter) = FFT(filtered data)