Q:

Multiplying 2 numpy arrays

I have two numpy arrays, the shape of the first array A is (36,) and the second one B is (36, 4). The idea is to multiply corresponding elements like A[0] * B[0] in the way that each of 4 elements of B gets multiplied with corresponding element of A.

A:

You need to add a new axis to A in order to enable broadcasting.
import numpy as np

A = np.random.randint(0, 10, size=(36,4))
B = np.random.randint(0, 10, size=(36,))

A * B.reshape(-1, 1)

