Random numbers: the urandom module

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
pythoncoder
Posts: 1311
Joined: Fri Jul 18, 2014 8:01 am

Random numbers: the urandom module

Postby pythoncoder » Mon Dec 19, 2016 7:43 am

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.
Peter Hinch

Return to “General Discussion and Questions”

Who is online

Users browsing this forum: No registered users and 3 guests