python list
L = [1,2,3]
numPy array
A = np.array([1,2,3])
append to list and append to array
L.append(4)
A + np.array([4])
python list of lists and select the first element of the list
L = [[1,2],[3,4]]
L[0]
numPy matrix and selecting items from it
A = np.array([[1,2],[3,4]])
# show row 1, column 2
print(A[0][1])

# also show row 1, column 2
print(A[0,1])

#selects the entire first column column
print(A[:,0])
numPy dot function
a = np.random.randn(100)
b = np.random.randn(100)
a.dot(b)
What is Dot Product?

Dot product occurs when two vectors are multipllied. The result is a scaler (ie a number, not a vector) Example:

Find the dot product of vector a and vector b

vector a = a1, a2, . . . . , an

vector b = b1, b2, . . . . , bn

vector a * vector b = a1b1 + a2b2 + . . . . + anbn

generating data for a numPy array and matrix matrix
# array of 100 normally distrubuted numbers
a = np.random.randn(100)

# matrix of size 100x100 which random integers between 0 and 1000
a = np.random.randint(0,1000, size=(100,100))
# example
>>> import numpy as np
>>> print(np.random.randint(0,10, size=(10,10)))
[[8 4 3 3 3 0 8 3 6 5]
 [6 0 0 8 8 9 5 8 1 0]
 [1 9 3 6 4 0 4 8 6 3]
 [6 2 3 4 7 9 3 4 5 4]
 [9 3 7 4 4 6 6 2 5 5]
 [1 9 2 1 5 5 1 7 9 5]
 [7 5 9 1 9 7 2 5 8 5]
 [7 1 8 9 0 5 9 8 2 3]
 [2 7 5 2 1 2 1 2 7 3]
 [5 0 4 9 0 0 5 9 1 6]]