07 Numerical Computation Flashcards

(19 cards)

1
Q

One dimensional array

A

Collection of numbers which we can access by index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the default type of NumPy array

A

Float

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Shape

A

Tells us size of the array in each direction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

arange

A

Creates an array with equally spaced values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the downside of the flexibility in python lists?

A

performance
slow computation speed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are 3 ways to create arrays in python?

A
  • np.array(x)
  • numpy.arange(x)
  • numpy.linspace(x)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

arange

A

creates an array with equally spaced values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

linspace

A

creates array with prescribed start and end values, all equally spaced

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

do NumPy arrays support common arithmetic operations?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Vectorisation

A

manipulation of arrays without indexing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does the performance of specialised functions compare to your own general implementations?

A

Specialised functions many orders of magnitude faster
e.g. NumPy sqrt vs computing it yourself

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do we index a 2D array?

A

Using two indices, first for row index and second for column index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do we compute matrix multiplication

A

_= .dot()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you compute the inverse of a matrix?

A

Ainv = np.linalg.inv(A)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you compute the determinant for a matrix

A

Adet = np.linalg.det(A)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Array slicing

A

Extract subsets of an array

17
Q

What is something you have to watch out for in array slicing

A

y = x[1:3] will get values 1 to 3 but NOT including 3

18
Q

How do we slice from the start of an array

A

e.g. y = x[:3]
start to (3)

19
Q

How do we slice from the end of an array