Member-only story
High Quality Random Number Generation using NumPy for Cryptography, Security, Simulations, and Sampling
The other day, I was reading about random number generators in Python, as random number generation is a cornerstone in numerous computational, scientific and security-based applications.
I decided to do a little research about the wrapper class Generator in NumPy, which has a number of methods for generating random numbers. Generator class uses BitGenerator to manage the seed or set/get or manipulate the state.
Statistical properties of what’s available in BitGenerator differ (refer to code examples at the end), and the quality of randomness significantly impacts the accuracy and security.
The default BitGenerator is PCG64 generator, and you may want to use others as certain use-cases demand the different statistical properties of random numbers to ensure accuracy, security, or both.
Use Cases That Require The Highest Quality Random Numbers
But before getting into the details, let’s have a look at a few use cases that require the highest-quality random numbers:
1 → Cryptography: This is perhaps the most critical application requiring high-quality randomness. Cryptographic keys, initialization vectors…