Sorting NaNs

Michael Lamparski diagonaldevice at gmail.com
Thu Jun 7 19:49:45 EDT 2018


On Thu, Jun 7, 2018 at 4:43 PM, Peter Pearson <pkpearson at nowhere.invalid>
wrote:

> But gosh, if there are only 2**32 different "random" floats, then
> you'd have about a 50% chance of finding a collision among any
> set of 2**16 samples.  Is that really tolerable?
> --
> https://mail.python.org/mailman/listinfo/python-list
>

In any case, it's verifiably not true for CPython.

> >>> def birthday(b):
> ...   rand = random.random
> ...   xs = [rand() for _ in range(2**b)]
> ...   return len(xs) - len(set(xs))
> ...
> >>> birthday(24)
> 0
> >>> [birthday(24) for _ in range(10)]
> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Michael



More information about the Python-list mailing list