vendredi 9 juillet 2021

Verify uniform distribution of discrete values in Python?

I'm using random.SystemRandom().choice(list_), and need confirmation that it gives uniform discrete distribution for cryptographic purposes across CPython 3.x versions.

Does anyone know if it's uniform in CPython 3.0 - 3.9? random.SystemRandom is at least present in all of these, though 3.2 has problems with too-new versions of openssl.

Alternatively, is there an easy way of verifying it mathematically, perhaps using scipy or something? Please note that it needs to be discrete, not continuous. I do not have a background in statistics.

In a "string" histogram, it looks like:

1675814 0 ************************************************************
1677567 1 ************************************************************
1677969 2 ************************************************************
1678564 3 ************************************************************
1676721 4 ************************************************************
1677222 5 ************************************************************
1679371 6 ************************************************************
1678663 7 ************************************************************
1676892 8 ************************************************************
1678433 9 ************************************************************

...which seems good that far, but I don't know if that's considered uniform.

Thanks!




Aucun commentaire:

Enregistrer un commentaire