-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
So I wanted to generate some unique integers with the following code:
import numpy as np
max_int = np.iinfo(np.uint32).max
numbers = np.random.choice(max_int, 10, replace=False)I wanted these numbers as deterministic seeds for some simulations. When I do this almost 16 GB of memory are filled.
I looked into the code for choice and in this case it essentially generates a permutation, similar to shuffling a np.arange(max_int), in order to then take a small slice from that array. This seems like a bad strategy since providing only an int to random.choice makes it clear that numbers in that range should be sampled. At least when the integer argument a is much larger than the argument size.
So for now I will just generate a set of numbers but I was wondering if there is a more general way.
pelegm, J535D165, vitchyr, sheikirfanbasha, Prikers and 1 more