My notes for this page:

How random is chance actually? Heads or tails in theory and practice.

Slide 0

A warm welcome to all of you. Today we’d like to talk about mathematics again and once again we’ll address chance. How random is chance actually? We will clarify this question, and in the process again see that our intuition in this field is not always the best guide.

Slide 1

Flip a coin. No, not really. Just pretend that you are flipping a coin. Take a pencil and paper and write down a sequence of 25 flips that you randomly select. Of course, you may use just an H for heads and a T for tails. Get started.

Slide 2

Now please take a coin and really flip it 25 times. Naturally, you should also record this sequence in writing.

Slide 3

Look at the sequence you made up. How often did only the letter H or only the letter T occur in a row for you?

Fewer than five times? Five or more times?

Are there differences between the “pretend” sequence you wrote down and the real coin flips?

Slide 4

I also participated in this activity and conducted the experiment four times in a row, so I flipped the coin a total of 100 times. Here are the results. Altogether, I came up with “heads” 51 times and “tails” 49 times, surprisingly almost an even frequency distribution.

However, of course the heads and tails didn’t always nicely alternate one after the other. In the first series, heads turned up 6 times in a row at the beginning. The second series even started with 9 flips of tails.

If you compare your made-up sequence with my series, it probably looks more like the third and fourth sequences here. A sequence of five identical flips may be the exception, right? Purely intuitively, we shy away from writing the same letter too often. However, we well know: Random events do not have memory. It means absolutely nothing to chance what result came up on the previous flip.

Slide 5

Let’s take a closer look at this. Clearly, it’s about the following:

What is the probability that in a sequence of 25 flips, the same side of the coin comes up five or more times in a row? To answer this question, we’ll use a random number generator as an aid. In the process, 10,000 random flips were observed. The result is on the next slide.

Slide 6

The chart shows the distribution of the maximum number of the same element in a row. On the left-hand side marked in yellow are the sequences in which the maximum number of identical elements in succession was two, three, or four. Clearly, the number was exactly four for the most sequences.

However – and you see this on the right-hand side in blue – in more than 50% of the cases, the longest sequence of the same element in a row for these 10,000 experiments was at least five elements in succession and the maximum overall was an impressive eleven elements in succession.

Slide 7

After the random number generator had its turn, now people shouldn’t go unheard. You see the numbers. In an experiment with 32 people, about 30% had written down a sequence with five or more elements.

Okay, 32 is of course considerably lower than 10,000. And we have already extensively discussed the "empirical law of large numbers".

Slide 8

Nevertheless, it appears that people do not have a particularly good sense of chance. Surely, nothing is better than the real experiment.

However, does a random number generator really work more reliably than a person? Let’s take a closer look at this. Specifically, we’ll address these three questions:

What does a random number generator do?

How does it do that?

How random are the results really?

Slide 9

What does the random number generator in a computer actually do?

It’s quite simple: It can generate numbers randomly. Normally, these are numbers between 0 and 1 that, for instance, are generated to 8 or more decimal places exactly. But surely, you’re also familiar with applications in which the results are whole numbers. They then lie within certain limits that you can determine yourself, such as between 1 and 6 to simulate rolling a die.

But how does this actually happen?

Let’s understand this step by step.

Slide 10

Actually, it’s always just about generating single digits randomly.

Imagine a wheel with the digits from 0 to 9, as shown here. If you spin it repeatedly, in this way you end up with a random sequence of digits.

Provided that the fields are the same size and you really spin the wheel, the result is a sequence in which every single digit between 0 and 9 occurs with approximately the same probability for a large number of such spins.

Slide 11

How do we get the desired random numbers? It’s quite simple.

Let’s assume that we have obtained a long list of randomly generated digits. If you now group four successive digits, for example, you come up with one of 10,000 possible numbers between 0 (“0000”) and 9,999 (randomly created).

And if you would rather have a number between 0 and 1, you simply start with “0” and add on four decimal places.

In any case, you call that a random number.

Slide 12

Certainly, the computer doesn’t contain a wheel. In the end, it can only work with algorithms. We therefore need suitable algorithms for generating corresponding numbers. This has a bit of a bad reputation because the process can no longer be completely random – we’ll look at this again later in detail. However, because an algorithm is behind the results, we speak of pseudorandom numbers.

What requirements do we place on the numbers and thus on such an algorithm?

Let’s assume that four-digit numbers are to be generated. Then the digits between 0 and 9 should each occur about one-tenth of the time, all two-digit sequences about one-hundredth of the time, and all three-digit sequences about one-thousandth of the time (at least “in the long run”, thus when you generate a great deal of numbers).

Slide 13

One possible algorithm has a simple operating principle: It must start with one digit and use it to generate the next digit. In principle, the process could work like this:

We choose a number a1to begin with, multiply it with another fixed number b, add another number c, and finally look at the remainder when we divide by d. The result is a2.

Too many variables? Too abstract? As is almost always the case, this is considerably easier with an example.

Slide 14

Let’s use specific numbers. We select a1 = 2, b = 3, c = 4 and d = 10. We calculate a1 • b + c = 2 • 3 + 4 = 10, thus a2 = 0.

And so it continues:

0 • 3 + 4 = 4, thus a3 = 4.

4 • 3 + 4 = 16, thus a4 = 6.

6 • 3 + 4 = 22, thus a5 = 2.

2 • 3 + 4 = 10, thus a6 = 0.

Slide 15

Oh, it really shouldn’t be like this because in this case, the sequence 0, 4, 6, 2 repeats immediately and continuously 0, 4, 6, 2, 0, 4, 6, 2, etc.

There’s no trace of chance with this fixed sequence and the sequence doesn't even include all numbers between 0 and 9. Apparently, it’s not quite so simple.

Slide 16

Is changing variable d sufficient?

For a1 = 2, b = 60, c = 5 and d = 100 you calculate 2 • 60 + 5 = 125, thus a2 = 25.

Slide 17

And so it then continues: This is completely dreadful because a3 = a4 = a5 = a6 =  all others are equal to 5. No, this doesn't work either; clearly, the variables must be selected somewhat more cleverly.

Slide 18

More cleverly, yes. But in principle it isn’t more difficult. You simply have to select the starting values a1, b and c so that for the desired number of digits – and that is determined by the variable d – as many numbers as possible occur as remainders.

For a1 = 2, b = 72, c = 5 and d = 100, things already look better.

We calculate 2 • 72 + 5 = 149, thus a2 = 49.

And so it continues:

49 • 72 + 5 = 3533,   thus a3 = 33.

33 • 72 + 5 = 2381,   thus a4 = 81.

81 • 72 + 5 = 5837,   thus a5 = 37.

37 • 72 + 5 = 2669,   thus a6 = 69.

But to be very clear: For division by 100, only the 100 remainders between 0 and 99 can occur. Eventually, a remainder will repeat and then the entire sequence will start identically again from the beginning. If you spin a wheel, that is less likely to happen. And that’s exactly why we distinguish between random numbers and the pseudorandom numbers generated here.

By the way, in practice the d chosen is large. For d = 1 million there are theoretically 1 million remainders and thus – when the other variables are selected suitably – a greater opportunity for different pseudorandom numbers.

Slide 19

Once again: Clearly, it greatly depends on which starting values are used for the variables.

That’s why in reality, people work with a large d and whole numbers for which the stated quality factors of the sequence are met. For instance, you multiply the starting number a1 by 16807 and divide the result by 2,147,483,647. And please don’t ask me how anyone came up with precisely these numbers.

Slide 20

The last step might be the easiest. What do you do if you really want to have exactly the natural numbers between 1 to 6?

There’s nothing easier.

If you have good random numbers between 0 and 1 at hand, then you rate all numbers between 0 and 1/6 as 1, between 1/6 and 2/6 as 2, between 2/6 and 3/6 as 3, and … all between 5/6 and 6/6 as 6.

Nevertheless, you shouldn’t give up playing with a real die.

Slide 21

It’s nice that you were here. I look forward to seeing you when we talk about math again in the next episode.

Tip: Log in and save your completion progress

When you log in, your completion progress is automatically saved and later you can continue the training where you stopped. You also have access to the note function.

More information on the advantages