One dimensional array
Collection of numbers which we can access by index
What is the default type of NumPy array
Float
Shape
Tells us size of the array in each direction
arange
Creates an array with equally spaced values
What is the downside of the flexibility in python lists?
performance
slow computation speed
What are 3 ways to create arrays in python?
arange
creates an array with equally spaced values
linspace
creates array with prescribed start and end values, all equally spaced
do NumPy arrays support common arithmetic operations?
Yes
Vectorisation
manipulation of arrays without indexing
How does the performance of specialised functions compare to your own general implementations?
Specialised functions many orders of magnitude faster
e.g. NumPy sqrt vs computing it yourself
How do we index a 2D array?
Using two indices, first for row index and second for column index
How do we compute matrix multiplication
_= .dot()
How do you compute the inverse of a matrix?
Ainv = np.linalg.inv(A)
How do you compute the determinant for a matrix
Adet = np.linalg.det(A)
Array slicing
Extract subsets of an array
What is something you have to watch out for in array slicing
y = x[1:3] will get values 1 to 3 but NOT including 3
How do we slice from the start of an array
e.g. y = x[:3]
start to (3)
How do we slice from the end of an array
y = x[4:]