# How do computers generate random numbers 3

## Mathematics: How does chance get into the PC?

Random numbers are also needed for many other purposes, such as simulating car traffic or the weather in a computer. However, choosing a random number is difficult for a computer. Computers are obedient arithmetic servants: they carry out a calculation exactly as it was previously specified. They don't deviate by a millimeter unless the computer is defective.

Lotto with the computer would be boring: every week we would have the same result. Or is it possible to generate a sequence of random numbers with a computer program?

Well, true random numbers in the strict mathematical sense cannot actually be generated with a computer - but at least so-called pseudo-random numbers. These are sequences of numbers that, according to statistical tests, look random. They are not really random, but they are so “mixed up” that they are nevertheless suitable for computer simulations.

John von Neumann, a mathematical genius and one of the first to calculate with computers, invented a simple method for generating pseudo-random sequences. Take, for example, a ten-digit decimal number. If this number is squared, the result is an approximately 20-digit number. Now take the middle ten decimal places. This is the first pseudo random number. Then you repeat this process over and over again: square again, take ten places from the middle, and so on. Each time a new pseudo-random number is created. This procedure does not work with every starting number, but with certain starting values ​​the results look really chaotic.

Another method for generating pseudo-random numbers by computer is the so-called congruence method by Lehmer. It has already been used on Eniac, the world's first electronic computer. As with the Von Neumann method, you start with a number. This is multiplied by 23 and then by 10 8 +1 (100 million plus one) divided. The remainder is the first pseudo-random number. You start the next bill with it - and so on. The sequence of numbers generated in this way has good statistical properties, that is, it looks random.

The methods mentioned are easy to implement in a computer or even a calculator. Basically, the more decimal places are used, the more random the sequence of numbers looks.

The author is a professor of computer science at the Free University of Berlin. His specialty are artificial neural networks.

More math columns on the web:

www.jahr-der-mathematik.de

welt.de/mathematik