import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
%matplotlib inline
# A toy example shows how a sequence of samples from
# a time domain is mapped into a frequency domain using
# a Discrete Fourier Transformation.
k = np.arange(0,8)
x = np.cos(2*k*np.pi/4)
plt.stem(k, x, use_line_collection=True)
X = sp.fft.fft(x)
print(X)
F = np.linspace(0, 1, len(X)+1)
F = F[:-1]
plt.stem(F, np.absolute(X), use_line_collection=True)