Random

Updated: 09/03/2019 by Computer Hope
Illustration: two six-sided dice, a way to produce random numbers.

The term random refers to any collection of data or information that has no determined order, or is chosen in a way that is unknown beforehand. For example, 5, 8, 2, 9, and 0 are single-digit numbers listed in random order. Random data may be re-ordered, or sorted, by date, name, time, age, etc., in which case its order is no longer random.

Data can be randomly selected, or random numbers can be generated using a random seed. Computer games, web pages, programs, and encryption are a few examples of things that need random values to operate. For example, Computer Hope has a tool that randomly selects and opens a random dictionary page for Computer Hope users.

Example of a random number

Below is an example of a random number generated from a custom seed. Enter any text into the custom seed box and click the generate button. This widget uses Johannes Baagøe's open source PRNG scripts, Alea.js and Mash.js.

Input a custom seed (a number or phrase):

number generated from seed :

Random number in programming

In programming languages, there is often a command, function, or random number generator (rng) that allows the developer to generate a pseudorandom number. For example, in Perl, the rand function returns a random number between 0 and a number that you specify.

my $random = int(rand(10) + 1);
print "Random number between 1 and 10: $random\n";

Here, the variable random is assigned a random integer value between zero and ten, rounded down, plus one. The result is a whole number between 1 and 10.

Random number in Microsoft Excel

You can create a random number in excel by using the rand or randbetween function. See our Excel formula page for help with these functions and examples.

Ascending order, Prime number, Programming terms, Random seed, Shuffle