Hamburg --:-- EN DE TR Email
← All posts

Does the universe roll dice, or does it count?

An evening conversation that started with 100 coin flips: randomness, a spreadsheet, and a question in quantum physics that is still open.

One evening I asked Claude for something simple: write Python code that flips a coin 100 times, and let's see how many heads and how many tails come up. The code was five lines; the result was 43 heads, 57 tails. I raised the number of flips to 10,000: 5,010 heads, 4,990 tails.

My first reaction was admiration: what a nice randomness mechanism the programmers have built — the result is so close to 50%. Then the question changed. Then it changed again. In the end I found myself in the middle of one of the fundamental debates of quantum physics. This post is the record of that conversation; we ran every piece of code in it together, and the tables are real output.


1. The balance comes from mathematics, not from the software

Here is the code:

import random

results = [random.choice(["Heads", "Tails"]) for _ in range(100)]
print("Heads:", results.count("Heads"))
print("Tails:", results.count("Tails"))

Nowhere in it is there a line that says "keep things balanced". Every flip is an independent 50/50 choice that knows nothing about the one before it. That the total still settles near 50% has a name: the law of large numbers.

The subtle part is this: the deviation doesn't actually shrink — it grows. After n flips the expected deviation is roughly √n/2. Because the total grows faster, the deviation melts away as a percentage:

      Flips     Heads   Diff (count)   Diff (%)    √n/2
-------------------------------------------------------
         10         5              0      0.00%       2
        100        46              4      4.00%       5
      1,000       489             11      1.10%      16
     10,000     5,017             17      0.17%      50
    100,000    50,120            120      0.12%     158
  1,000,000   499,410            590      0.06%     500

In absolute terms the difference climbs from 4 to 590; as a percentage it falls from 4% to 0.06%. The deviation grows with √n, the total with n; their ratio is 1/√n, and that goes to zero.

Seen this way, my 10,000-flip result isn't surprising at all: the expected deviation is around 50, mine was 10. Had it come out exactly 5000/5000, that is when I should have been suspicious.

2. The programmers' real achievement

Mathematics starts with "if every flip is independent and equally likely". Meeting that condition is the hard part.

Python's random module uses the Mersenne Twister (MT19937). It is a completely deterministic algorithm: given the same starting value (seed), it produces the same sequence every time. But the sequence only repeats itself after 2¹⁹⁹³⁷−1 steps. For comparison: the number of atoms in the universe is around 2²⁶⁶. On top of that, every combination of up to 623 consecutive numbers comes up equally often. And that is exactly what is hard: making every number come up equally often is easy; having no hidden pattern at all is hard.

There is also a quiet trap. Taking a random number modulo the length of a list (number % 3) looks innocent but is broken: take a number between 0 and 255 modulo 3, and the first element comes up 86 times, the others 85 times each. Python instead uses "generate enough bits; if the result falls outside the range, throw it away and generate again" (rejection sampling). It deliberately does extra work to get the right result.

A small note: this statistical quality does not mean security. Someone who sees 624 consecutive outputs of the Mersenne Twister can work out its internal state and predict every number that follows. For passwords and keys, use the secrets module.

3. The real question: is randomness real?

Up to this point it was all about computers. Then something else started to bother me.

In quantum mechanics a particle behaves as if it were "waiting" in two states at once until it is measured; measure it, and one of them happens while the other disappears. What if this is not real randomness? What if, at the smallest time scale, the universe runs in a regular pattern like 0101010101..., and we only see something random because we look at that sequence at coarse intervals?

There is a real mechanism behind this intuition: aliasing. It is why a car's wheels seem to spin backwards in films. Sample a fast pattern slowly and you get a false picture. And the difference in scale is not imaginary: the Planck time is about 5.4×10⁻⁴⁴ seconds, while the shortest time interval ever measured is 247 zeptoseconds (2.47×10⁻¹⁹ seconds). Between the two lies a factor of more than 10²⁴. There is plenty of room down there for things to happen.

But 0101 is exactly the kind of order that doesn't work. I sampled this sequence at different intervals:

step    1: 01010101010101010101...   share of 1s = 50%
step    2: 00000000000000000000...   share of 1s = 0%
step    3: 01010101010101010101...   share of 1s = 50%
step    7: 01010101010101010101...   share of 1s = 50%
step 1024: 00000000000000000000...   share of 1s = 0%

Sample a periodic source at fixed intervals and you don't get randomness, you get another periodic thing: with an even step, always the same result; with an odd one, a regular oscillation. If the universe really worked like this, we would have noticed in the very first experiment.

But the source doesn't need to be periodic; being deterministic is enough. There is no randomness at all in this rule:

x = 0.30000000001
for _ in range(100_000):
    x = 4 * x * (1 - x)          # logistic map
    bit = 1 if x > 0.5 else 0

The output goes 11100010100110011001..., and the share of 1s is 49.82%. An eight-character formula produces a sequence that is statistically indistinguishable from coin flips. When I nudged the starting value by one part in a trillion (0.300000000011), the two sequences split at the 38th bit and never met again. Same rule, a completely different future.

The lesson: being deterministic and being predictable are not the same thing. Order can be chaotic.

4. The spreadsheet: what if the columns were time?

To make the idea clearer, I made a table:

Column (time) →   A  B  C  D  E  F  G  H  I  J  K  L  ...
Coin              0  1  0  1  0  1  0  1  0  1  0  1  ...
Die               1  2  3  4  5  6  1  2  3  4  5  6  ...
Three-sided       1  2  3  1  2  3  1  2  3  1  2  3  ...

The columns are time. At the smallest time scale, the universe works like a counter, scanning the six faces of the die in order, never missing a beat. The statistics are guaranteed from the start: every face gets exactly 1/6, because the counter passes over all of them equally often. When we roll a die, the only thing that happens is which column of the running counter we happen to land on. What we call "chance" is a property not of the event, but of our position in time.

Let's call this the "odometer universe". The idea has a respectable pedigree: Ludwig Boltzmann's ergodic hypothesis from the 1870s says almost exactly this. If a system passes through all of its possible states over a long enough time, the time average equals the probability average. The whole edifice of statistical mechanics rests on this assumption.

5. The odometer universe leaves a fingerprint

The idea is beautiful — and precisely for that reason, it can be tested.

A counter balances its results by itself. If it has shown too many 6s, it inevitably passes the other faces and closes the gap. The deviation hits a ceiling and stays there. A real die has no memory and closes no gaps; its deviation wanders freely and grows with √n.

I compared the two. In the odometer universe the die turns from 1 to 6 in order, and we look at it at fixed intervals that share no rhythm with the counter (the golden ratio). Opposite it is an ordinary random die. The table shows how far the "number of 6s" deviates from the expected value n/6:

          n   Odometer     Random   Expected σ
----------------------------------------------
        100        0.7        3.3            4
      1,000        0.3        4.3           12
     10,000        0.7       89.3           37
    100,000        0.3       86.3          118
  1,000,000        0.7      123.3          373

In the odometer universe the deviation stays below 1 even after a million rolls. For the random die it climbs into the hundreds. (The 89 in the 10,000 row is a slightly unlucky deviation, about 2.4σ. The random column changes on every run; what matters is the growth trend.)

In both worlds every face converges to 1/6, but in different ways. The odometer universe would be "too tidy" compared with the real one. That is a measurable difference, and quantum random number generators show √n behaviour in standard tests. At least in the layer we can reach, the universe does not close its gaps.

6. The rescue, and its price

There is a way to rescue the model: say "we land on the counter at random moments", and the distribution becomes normal again and √n comes back.

But the moment you say that, you haven't removed randomness; you have moved it. The outcome of the die is now deterministic, but "which column we land on" is random. So what determines the moment of our measurement?

  • If the moment of measurement is deterministic too, then which column you land on is also written in advance. You didn't choose to roll the die; the counter found you rolling it in that column. This is called superdeterminism. Logically it is flawless, but the price is heavy: if the experimenter's choice is part of the same sequence as the thing being measured, the notion of an "independent experiment" loses its meaning.
  • If the moment of measurement is random, you are back where you started. The randomness is still in the universe; it has just moved from the face of the die to the face of the clock.

We can also put this in the language of information theory. If the outcome is a deterministic function of the sampling moment, the uncertainty (entropy) of the outcome cannot exceed the uncertainty of the sampling moment: H(outcome) ≤ H(moment). The counter model doesn't cut the randomness budget at all; it just books the bill under a different item.

Perhaps randomness is not an object in the universe at all, but the name of the point where the chain of explanation hits bottom, wherever you push it.

7. We checked the literature: the idea already has owners

We looked at the literature to see whether a paper could come out of this. The short answer: no, because every layer of the idea has been thought of before. But who thought of it is interesting.

The philosophical thesis. The Nobel laureate physicist Gerard 't Hooft argues exactly this in his book The Cellular Automaton Interpretation of Quantum Mechanics (2016): underneath quantum mechanics there may be a deterministic cellular automaton running at the Planck scale.

The statistical test. Kavulich, Van Deren and Schlosshauer (Physics Letters A, 2021) ran algorithmic randomness tests on 100 sequences of 1.68 billion bits each, taken from the quantum random number generator of the Australian National University (ANU). To bring 64,000-bit sequences from a second quantum generator up to the same length, they looped them, and they also used these looped sequences to see whether the tests would catch the repetition. They found no statistically significant difference between quantum generators and classical pseudo-random generators.

The "deviation hits a ceiling" signature also has standard names in the literature: a Hurst exponent H < 0.5 (anti-persistence, i.e. a tendency to revert) and low-discrepancy sequences. That the latter fail standard randomness tests is textbook knowledge. So the simple version of the odometer universe is already ruled out by existing tests.

The rescued version. Here is the most surprising part. The idea that "the hidden variable changes over time, and if you measure fast enough, you'll catch it" is exactly the experiment Sabine Hossenfelder and Tim Palmer proposed in their paper Rethinking Superdeterminism (2020). Their proposal, roughly: states prepared as identically as possible, devices as small and as cold as possible, and time intervals as short as possible.

Time intervals as short as possible: the columns of the spreadsheet. This experiment has not yet been done convincingly; but it is work for a laboratory, not for a desk.

One detail: the Bell tests behind the 2022 Nobel Prize in Physics (Aspect, Clauser, Zeilinger) rule out local hidden-variable models, but they cannot rule out superdeterminism. Hossenfelder says so plainly: Bell-type tests will never be able to tell superdeterminism apart from quantum mechanics. The route she proposes is to look for deviations from the Born rule in small, cold systems.

8. Closing: even if fate is written

Suppose 't Hooft is right and the universe really is a deterministic automaton. Does anything change?

Stephen Wolfram has a concept he calls computational irreducibility: for some deterministic systems, there is no shorter way to learn their future than to run them step by step. The universe is its own fastest simulation, and we are inside it. Even if fate is entirely written, no one looking from the inside can read it in advance.

Perhaps the real question is this: if no experiment can tell "truly random" apart from "deterministic but inaccessible in principle", does the difference mean anything?

The spreadsheet has one more property: all the columns sit on the sheet at the same time. Past columns are not erased; future columns are not waiting. In philosophy this is called the block universe, and it follows naturally from Einstein's theory of relativity. When his close friend Michele Besso died, Einstein wrote to the family that the distinction between past, present and future is nothing but a stubborn illusion.

From a coin-flip script, we have ended up here. Does the universe roll dice, or does it count? We don't know. But we now know which experiment could put the question to the test, and that is no small thing.


References

  • Gerard 't Hooft, The Cellular Automaton Interpretation of Quantum Mechanics, Springer (2016). arXiv:1405.1548
  • J. T. Kavulich, B. P. Van Deren, M. Schlosshauer, "Searching for evidence of algorithmic randomness and incomputability in the output of quantum random number generators", Physics Letters A 388, 127032 (2021). arXiv:2101.01238
  • S. Hossenfelder, T. N. Palmer, "Rethinking Superdeterminism", Frontiers in Physics (2020). arXiv:1912.06462
  • S. Hossenfelder, "Superdeterminism: A Guide for the Perplexed" (2020). arXiv:2010.01324
  • S. Grundmann et al., "Zeptosecond birth time delay in molecular photoionization", Science 370, 339 (2020).
  • Low-discrepancy sequence, Wikipedia
  • Documentation of Python's random module

Appendix: the code for the odometer experiment

import random

random.seed(42)
ALPHA = (5 ** 0.5 - 1) / 2   # golden ratio: a sampling rate with no rhythm in common with the counter

for n in [100, 1_000, 10_000, 100_000, 1_000_000]:
    # Odometer universe: the die scans 1..6 in order; we look at fixed but incommensurate intervals
    odo_six = sum(1 for i in range(n) if int(((i * ALPHA) % 1) * 6) + 1 == 6)
    # A real die
    rnd_six = sum(1 for _ in range(n) if random.randint(1, 6) == 6)
    expected = n / 6
    sigma = (n * (1 / 6) * (5 / 6)) ** 0.5
    print(n, round(abs(odo_six - expected), 1), round(abs(rnd_six - expected), 1), round(sigma))

This post grew out of a conversation I had with Claude. We ran the code and the tables together during that conversation.