In [5]:
# Getting set up to use the NumPy Library
import numpy as np
In [8]:
# Arrays have shape (dimensions) and data types
rows = 1
cols = 3
np.zeros(shape=(rows, cols), dtype=float)
Out[8]:
In [9]:
# Arrays have shape (dimensions) and data types
rows = 3
cols = 3
np.zeros(shape=(rows, cols), dtype=float)
Out[9]:
In [11]:
# Three dimensional array
rows = 3
cols = 3
depth = 3
np.zeros(shape=(rows, cols, depth), dtype=float)
Out[11]:
In [14]:
my_ones = np.ones(shape=(rows, cols), dtype=int)
my_ones
Out[14]:
In [13]:
print(my_ones)
In [31]:
a = np.arange(16)
In [32]:
a
Out[32]:
In [33]:
a[0:4]
Out[33]:
In [34]:
a[4:6]
Out[34]:
In [35]:
a[0:]
Out[35]:
In [36]:
a[:]
Out[36]:
In [40]:
a[:-1]
Out[40]:
In [39]:
a[::-1]
Out[39]:
In [38]:
a + 20
Out[38]:
In [41]:
a
Out[41]:
In [42]:
a.reshape(4, 4)
Out[42]:
In [46]:
a.cumsum()
Out[46]:
In [51]:
M = np.matrix('1.0 2.0 3.0 4.0; 5.0 6.0 10.0 11.0; 12.0 20.0 50.0 9.0')
In [52]:
M
Out[52]:
In [53]:
# Transpose
M.T
Out[53]:
In [62]:
X = np.matrix('100 0 0 0; 0 100 0 0; 0 0 100 0')
X
Out[62]:
In [63]:
M + X
Out[63]:
In [64]:
# Inverse
X.I
Out[64]:
In [1]:
print("Hello Linear Algebra")
In [2]:
print("Numbers, numbers, and more numbers")
In [19]:
# FFT Fast Fourier Transform
import numpy as np
PI = np.pi
t = np.linspace(0,120,4000)
signal = 12*np.sin(3 * 2*PI*t) # 3 Hz
signal += 6*np.sin(8 * 2*PI*t) # 8 Hz
signal += 1.5*np.random.random(len(t)) # noise
FFT = abs(np.fft.fft(signal))
freqs = np.fft.fftfreq(signal.size, t[1]-t[0])
In [16]:
Out[16]:
In [ ]: