def calc(N, m):
    x = 1.0
y = 2.0
container = np.zeros((N, 2))
nm = N * m
gamma_vals = np.random.gamma(3, 1, size=(nm,))
norm_vals = np.random.normal(0, 1, size=(nm,))
for i in range(N):
    for j in range(m):
        ij = i * j
x = gamma_vals[ij] / (y * y + 4)
y = norm_vals[ij] / np.sqrt(x + 1) + 1 / (x + 1)
container[i, 0] = x
container[i, 1] = y
return container
Speed up double loop in Python