fastest way to sample many random permutations of a numpy array
You can use rng.permuted
instead of rng.permutation
and combine it with np.tile
so to repeat x
multiple times and shuffle each replicates independently. Here is how:
perms = rng.permuted(np.tile(x, n).reshape(n,x.size), axis=1)
This is about 10 times faster on my machine than your initial code.