# How can a computer create random numbers?

Question by Guest | 2012-01-04 at 18:37

I wonder, how it is possible for computers to generate random numbers. Normally, I would think, as a layman, that a computer always works exact and accurate and a mathematical function always provides a predictable result. So, where are the numbers from the random number generator coming from?

## Related Topics

### Windows Batch Script: Computer Shutdown

Tutorial | 2 Comments

### MySQL: Add or Insert Random Number

Tip | 0 Comments

### Create random Words from specific Syllables

Tutorial | 0 Comments

### The Askingbox Search

Info | 0 Comments

### Put Windows via Script into Hibernation or Sleep Mode

Tutorial | 0 Comments

### JavaScript: Create random numbers

Tip | 0 Comments

## Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

## Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.

There are different ways, how a computer can proceed. First, there are so-called pseudo-random number generators. They just use a list of previous defined random numbers from which just a number is selected. Of course, that is not truly random and there is the problem, that the numbers forcibly repeat sometime, depending, of course, on the length of the list.

Better results are obtained with a different class of random number generators, which are processing certain "random" values from the computer to derive random numbers from them. This can be, for example, the computer's clock in milliseconds, that is constantly changing, or the moving of the mouse, or the noise of a sound input or a card attached to the computer. The resulting values are relatively unpredictable and thus lead to very good results, which look pretty random, after being chased by a corresponding function.

To test how good a random function is, it can be called a million times, to then look at the distribution of the output values. Here, the distribution should be quite equal and there should occur no unexpected spikes or depressions at certain values.

2012-01-05 at 19:59

There are mathematical functions that already vary enormously with small changes in the values of the parameters. If you put in these functions, for example, the system time as an initial value, quickly the whole range of values is uniformly covered and we get our random number by scaling to the desired range.

2012-01-06 at 21:34

There are no real random generators. All what these devices do is creating numbers that appear to be random. They use complex mathematical algorithms and functions, generating numbers that we hope will pass the test of time, and as we know from the past, time isn't a reliable partner.

There are two options to get random numbers

1. measuring the decay of nuclear material;

2. cosmic background radiation.

The results will be random until scientists discover the processes that control these events and they will become deterministic.

2020-07-01 at 10:16