Content Disclaimer
Copyright @2020.
All Rights Reserved.
StatsToDo : Random Numbers

Links : Home Index (Subjects) Contact StatsToDo

Introduction Programs Codes
This page provides algorithms for producing pseudo-random numbers. They are random because they have no discernable patterns, but they are not truly random because they are mathematically determined.

Scientifically, pseudo-random numbers are used to randomly allocate cases into different groups in controlled experiments, or to create random events in data modelling. Pseudo-random numbers are not considered encryption grade, and should not be used to encrypt information with serious security implications.

The basic random number generator produces a real number between 0 and 1. These can then be further converted into the following

  • Random real numbers that are normally distributed
  • Integers within a range
  • Clustes of ranged numbers in random order (shuffled)
The following random number generators are demonstrated on this page. It should be noted that each one generates different sequences that have different properties.
  • Javascript Math.random() function generates a real number between 0 and 1 to 16 decimal places. However it cannot repeat the same sequence.
  • Javascript program using the Ran3algorithm (see references). This allows the assignment of a random seed, so that the same sequence of random numbers can be repeatedly generated. An additional feature is that, although the random number is generated to only 9 decimal places, the algorithm is integer based and portable, in that the same program written in any language in any operating system will produce the same sequences.
  • R and Python codes also allows the assignment of a random seed to generate the same sequence repeatedly. It also provides functions where random numbers that are normally or exponentially distributd can also be generated.
  • Please Note: Different programs will generate different sequences of random number. Even the same program may generate different sequences if the version of the algorithm is changed or the capacity of the memories upgraded (8, 16, 32, 64 ... bits). These changes do not matter unless the same sequence is to be used repeatedly.