I have 1024 sample points, and I would like to do really simple extrapolation using Fourier transformation. First I apply Fast fourier transformation on the data. My first intuition was that I just calculate the inverse fourier transformation on a larger interval. The result of the FFT is a collection of sinusoidal waves, so I expected that it's result is continuous at the end of the original interval.
I calculate the result with this formula:
$$ X[k] = \sum_{n=0}^{N-1} x[n] e^{\frac{i 2 \pi n k}{N}} $$
The extrapolation at the end of the interval looks like this:
I would like to avoid this "break" in the result.
The python source code is:
import numpy as np
import matplotlib.pyplot as plt
from scipy.fftpack import fft
# generate samples
data = np.zeros(1024)
for k in range(0, 1024):
data[k] = np.sin(k/20 * np.pi*2)
# apply FFT on samples
waves = fft(data)
# calculate the new data points from the FFT result
res = np.zeros(2048)
for k in range(0, 2048):
val = 0.0
for n in range(0, len(waves)):
# https://dsp.stackexchange.com/a/510/25943
val += waves[n]*np.exp(1.j * 2*np.pi * n * k / len(waves)) / len(waves)
res[k] = val.real
#plot the result
plt.plot(res)
plt.show()
