generating random tuples in python

per perfreem at gmail.com
Mon Apr 20 14:39:35 EDT 2009


hi all,

i am generating a list of random tuples of numbers between 0 and 1
using the rand() function, as follows:

for i in range(0, n):
  rand_tuple = (rand(), rand(), rand())
  mylist.append(rand_tuple)

when i generate this list, some of the random tuples might be
very close to each other, numerically. for example, i might get:

(0.553, 0.542, 0.654)

and

(0.581, 0.491, 0.634)

so the two tuples are close to each other in that all of their numbers
have similar magnitudes.

how can i maximize the amount of "numeric distance" between the
elements of
this list, but still make sure that all the tuples have numbers
strictly
between 0 and 1 (inclusive)?

in other words i want the list of random numbers to be arbitrarily
different (which is why i am using rand()) but as different from other
tuples in the list as possible.

thank you for your help




More information about the Python-list mailing list