Basic Algebra Flashcards
1
Q
Calculate the magnitude(lenght) of a vector! How in math and how with numpy shortcut?
A
Squareroot of: a12 + an2
numpy: from numpy import linalg as LA
LA.norm(vectorname)
2
Q
How to calculate the distance between two vectors? How in math and how in numpy?
A
Squareroot of: (q1-p1)2 + (q2-p2)2
LA.norm(a-b)
3
Q
How are matrices represented in Python. Are they for example a list?
How matrcies are created in numpy?
A
It is represented as a list in a list with a list being a row
A=[ [8,8,8,]
[7,7,7]
[6,5,3] ]
you use arrays.
l = np.arrange(9)
[0,1,2,3,4,5,6,7,8]
l.reshape(3,3)
[ [0,1,2,]
[3,4,5]
[6,7,8] ]
4
Q
What is a n x k matrix?
A
A matrix which has n rows and k columns.