Random Numbers
Last updated
Was this helpful?
Last updated
Was this helpful?
In the course of working with long numbers one may require a long stream of random numbers. Here we review methods for generating them.
The digits of the irrational numbers such as π and е are randomly distributed but of course cannot be said to be truly random. they are psuedorandom in that they satisfy all of the properties of randomness but are in fact comletey predictable if we know the generating function.
Psuedonoise generators employ a fixed-length shift register that will emit a very long sequence of random numbers before they repeat exactly. If we know the exact taps of the shift register then we can predict the number sequence precisely.
Random numbers are:
statistically independent
not necessarily uniformly distributed
create no visible pattern in an x-y plot:
The numbers generated by this widget come from RANDOM.ORG's true random number generator.
This example will generate a series of 10 integers in the [1,6] interval:
Unix and Linux provide two system devices for generating random number streams:
/dev/urandom
/dev/hwrng (hardware random number generator)
An example method to generate 10 million random bytes (this takes almost one second on an early 2008 Mac Pro running 2.8 Ghz Xeon processor) on the command line is:
On Linux, /dev/urandom (where u stands for unlimited) will reuse the entropy pool rather than blocking, while /dev/random will block when the entopy pool has drained.
To generate a sequence of random numbers in the bash shell:
The website provides an API that any remote application can access securly to obtain true random numbers.
The site has a little widget for generting a true random number between 1 and a maximum you specifiy. It for you. Here is an example (change wwww to www to enable it - GitBook crashes soon after ):
The site will generate a sequence of pictures of the coin tosses of your choice. This is all in fun.