Issue
I am trying to time the generation of psuedo-random arrays in ipython, using random.gauss() and list comprehension in a ubuntu terminal but it kills the environment after pausing for a while the environment is killed and returns to root. I'm doing this to time the difference between a pure Python approach vs using Numpy.
tried on ubuntu VM and Windows.
import random
I = 5000
mat = [[random.gauss(0, 1) for j in range(I)] for i in range(I)]
expected a array with a shape of 5000x5000 instead get killed.
Solution
Very large overhead to use standard python for such kind of things (after generation you have to operate on it, right?)
Please, use NumPy
import numpy as np
q = np.random.normal(size=(5000,5000))
print(q.shape)
that was pretty much instant
Answered By - Severin Pappadeux
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.