Week Four - Day One
Today, I am planning on using Scipy, Numpy, and other python libraries to work with using the Fast Fourier Transform and extracting the spectra from the brain. As the brain thinks, there will be various signals sent out that will come in the form of some type of wave, in which I use the Fast Fourier Transform to take the sine and cosine components and turn it into a periodic function.
I've also learned a bit about matplotlib which a python library that allows one to plot graphs or charts. Using (import matplotlib.pyplot as plt), one can just write plt.plot (x, y, 'bo') and then plt.show( ) and the graph will appear when you run the code. I've realized that 'bo' means that the displayed graph will show blue dots, more specifically, on a scatterplot. 'rs' would display red squares and g^ displays green triangles. Although I've also realized that the code I was using was for scatterplots and to get graphs with a grid, plt.grid(True) had to be used.
The same code I wrote was:
from scipy.fftpack import fft, ifft, fftfreq
import matplotlib.pyplot as plt
import numpy as np
theta = 4*np.pi
t = np.linspace(0, 4, 100)
x = np.sin(theta*t)*np.exp(-5*t)
sp = fft(x)
axis = -1
freq = fftfreq(t.shape[axis])
plt.plot(freq, sp.real, freq, sp.imag)
plt.grid(True)
plt.show()
In which it displays:
A periodogram is an estimate of distribution of data of a signal. The Boham, parzen, boxcar, and hamming are all different windows that restrict the mathematical function to a certain interval.
When using t = np.linspace(0, 4, 100), the default number of points it plots is 50 and you can change the number of points by chaning the last digit to another number, for example 100. The more points are ploted, the better the data is represented.
The same code I wrote was:
from scipy.fftpack import fft, ifft, fftfreq
import matplotlib.pyplot as plt
import numpy as np
theta = 4*np.pi
t = np.linspace(0, 4, 100)
x = np.sin(theta*t)*np.exp(-5*t)
sp = fft(x)
axis = -1
freq = fftfreq(t.shape[axis])
plt.plot(freq, sp.real, freq, sp.imag)
plt.grid(True)
plt.show()
In which it displays:
A periodogram is an estimate of distribution of data of a signal. The Boham, parzen, boxcar, and hamming are all different windows that restrict the mathematical function to a certain interval.
When using t = np.linspace(0, 4, 100), the default number of points it plots is 50 and you can change the number of points by chaning the last digit to another number, for example 100. The more points are ploted, the better the data is represented.
No comments:
Post a Comment