Hi Carlo,

the random number generator returns either integer or floating point
numbers. If you pick the floating point option (which is the default),
then the chances are exceedingly small that you end up with identical
numbers. However, since only a finite number of values actually
represent valid numbers, there's always the chance (and eventually the
guarantee) that you'll get duplicates.

There are a number of solutions however:

1) filter out duplicates after you generate the random list. This is
quite tricky in grasshopper since it involves copious amounts of
looping and conditionals.

2) generate a controlled list of unique numbers, and sort those with a
random list. This is probably the best solution for you. So, create a
Range or List component and generate a list of N incrementing numbers
(we'll call this List A). Then, use a Random compnent to generate a
list of N random numbers (List B) (some of which might be duplicates).
Then, use the sort component to sort List B while synchronously
sorting List A. The output of the synchronous sort will now be a list
of number, without duplication and without a perfect distribution over
the domain.

--
David Rutten
Robert McNeel & Associates



On Sep 10, 12:38 pm, CMC <[EMAIL PROTECTED]> wrote:
> Is there a way to generate a list of random numbers without
> duplicates?
> If I use the random component in Grasshopper I get a list of numbers
> with few numbers that are repeated.
> THX
> Carlo

Reply via email to