Questions have been raised regarding producing random numbers on platforms lacking the Pyboard's hardware random number generator.
[edited]
The module urandom supports a pseudorandom number generator via the getrandbits function. This returns an n-bit pseudorandom number. urandom.getrandbits(30) works in a similar way to pyb.rng().
Note that pyb.rng() returns hardware generated true random numbers, whereas the output of getrandbits is deterministic.
Random numbers: the urandom module
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Random numbers: the urandom module
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.