numpy.random.uniform
supports array arguments, but np.random.randint
does not:
import numpy as np
two_random_uniforms = np.random.uniform([0, 1], [3, 4])
this_raises_exception = np.random.randint([0, 1], [3, 4])
The behavior I want from the second line of code is equivalent to:
result = []
for lown, highn in zip([0, 1], [3, 4]):
result.append(np.random.randint(lown, highn))
Is there a way to accomplish the random integer generation with variable max/min without writing a python loop? The above workaround will be unacceptably slow for the large arrays that my application requires. I can write the loop in cython, but I'd rather use Numpy if possible.
Aucun commentaire:
Enregistrer un commentaire