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

Kevin Jacobs <jacobs@bioinformed.com> bioinformed@gmail....
Thu Jun 14 07:55:40 CDT 2007


Call randint until you get enough bits of entropy to for a long with the
appropriate number of bits.

def randwords(n):
  result = 0L
  for i in range(n):
    result = (result<<32) | randint(0,2<<32-1)
  return result

-Kevin


On 6/14/07, Will Woods <will.woods@ynic.york.ac.uk> 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?
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070614/1412be6c/attachment-0001.html 


More information about the Numpy-discussion mailing list