[Numpy-discussion] randint for long type (permutations)

Robert Kern robert.kern@gmail....
Thu Jun 14 10:57:11 CDT 2007


Will Woods wrote:
> I want to choose a subset of all possible permutations of a sequence of 
> length N, with each element of the subset unique. This is then going to 
> be scattered across multiple machines using mpi. Since there is a 
> one-to-one mapping between the integers in the range 0 <= x < N! and the 
> possible permutations, one solution would be to choose M < N! integers 
> randomly, check for uniqueness, and then scatter only the integers so 
> that individual nodes can construct the permutations. However the 
> integers need to be of type long, and randint doesn't work for numbers 
> which cannot be converted to int. Any suggestions?

Is it too slow or bandwidth-consuming to generate the permutations on the master
node and then distribute the permuted arrays to the worker nodes? You can reduce
that somewhat by permuting arange(N) as an index array and send that to each of
the worker nodes.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco


More information about the Numpy-discussion mailing list