Numpy

Numpy is the core library for scientific computing in Python. It provides a high-performance multidimensional array object and tools for working with these arrays. A Numpy array is a grid of values, all of the same type, and is indexed by a tuple of nonnegative integers. The number of dimensions is the rank of the array; the shape of an array is a tuple of integers giving the size of the array along each dimension.
Numpy takes less computation time for multiplication of two matrices as it uses the technique of Vectorization which is very useful for complex model calculation.

#Import Numpy in Python
import numpy as np

How to create 1 rank array in numpy?

a = np.random.rand(5,1)
print(a)
[[0.28642857]
 [0.51330181]
 [0.92992345]
 [0.27376296]
 [0.21996422]]

Show how much time vectorized version take for calculation

import time

a = np.random.rand(1000000)
b = np.random.rand(1000000)
tic = time.time()
c = np.dot(a,b)
toc = time.time()

print("Vectorized Version " + str(1000*(toc-tic)) + "ms")
Vectorized Version 0.0ms

Show how much time for loop version take for calculation

c = 0
tic = time.time()
for i in range(1000000):
    c += a[i]*b[i]
toc = time.time()

print("For loop " + str(1000*(toc-tic)) + "ms")
For loop 1236.6154193878174ms