What are Random Numbers?
I did a wonderful #statistics experiment with students in stats class the other day on random numbers:
I divided the class into two groups. I gave a coin to one group and told them to flip this coin 20 times and record the resulting sequence of heads and tails. I asked the other group to come up with sequence of heads and tails in their heads and record the best sequence they can come up with. I told them I would leave the room and come back after five minutes, look at both sequences, and tell them which was created by the coin and which one in the heads of the other group.
These are the two sequences they came up with
HTTTTHHTHHHHTTHHHHTT
and
HTHTHTHTHTHTTHTHTTTH
Can you guess which sequence was constructed by what group?
Here is some background:
- Nice explanation using Markov Chains by Paul Ginsparg
- I had borrowed the idea from Ilya Perederiy, and especially from this vido by “numberfile” linked to on Ilya’s blog
- the post “Randomness: The Ghost In The Machine?” raises a few interesting philosophical questions, such as why Lady Justice, is usually both carrying sword/scales and is blindfolded, hence including an element of randomness to her. There is also some historical context, such as sometimes political leaders have been chose through random processes: “in Renaissance Venice, the doge was chosen by sortition — a type of lottery”, which a process that this wikipedia article confirms.
I believe that magical thinking is prevalent when it comes to randomness: “If I got tails, the next result will most likely be heads, because getting a head or a tail is equally probable and it should balance out.” But there is no higher power that counts outcomes and guides the coin to produce equal frequencies of heads and tails. See: https://en.wikipedia.org/wiki/Markov_property
The short python snippet below counts transitions from one result to the next. The second sequence is far more extreme than the first in this regard, as a head is always followed by a tail and a tail is most often followed by a head.
import numpy as np
r1 = “HTTTTHHTHHHHTTHHHHTT” r2 = “HTHTHTHTHTHTTHTHTTTH”
def transition_freqs(rr): rr = np.where(np.array(list(rr)) == “H”, 1, 0) freqs = np.zeros((2, 2), dtype=float) for last, cur in zip(rr[:-1], rr[1:]): freqs[last, cur] += 1 return freqs / freqs.sum(0)[None, :]
print(transition_freqs(r1).round(2)) print(transition_freqs(r2).round(2))
[[0.56 0.3 ] [0.44 0.7 ]] [[0.27 1. ] [0.73 0. ]]
So my bet is on the second sequence to be the one made up.
Dirk
26 Jun 19 at 12:39 pm