Chapter 5 - Basic Math and Statistics
Segment 2 - Multiplying matrices and basic linear algebra
import numpy as np
from numpy.random import randn
np.set_printoptions(precision=2)
Multiplying matrices and basic linear algebra
aa = np.array([[2.,4.,6.],[1.,3.,5.],[10.,20.,30.]])
aa
array([[ 2., 4., 6.],
[ 1., 3., 5.],
[10., 20., 30.]])
bb = np.array([[0.,1.,2.],[3.,4.,5.],[6.,7.,8.]])
bb
array([[0., 1., 2.],
[3., 4., 5.],
[6., 7., 8.]])
aa * bb
array([[ 0., 4., 12.],
[ 3., 12., 25.],
[ 60., 140., 240.]])
np.dot(aa,bb)
array([[ 48., 60., 72.],
[ 39., 48., 57.],
[240., 300., 360.]])