Warum zufällige Sprünge ein perfektes Dreieck zeichnen
Spring auf halbem Weg zu einer zufälligen Ecke, immer wieder. Aus reinem Zufall entsteht ein perfektes Fraktal.
Läuft nach einem Klick von YouTube.
Probier es aus: Ändere die Regel
Reiner Zufall, eine Regel: das Sierpiński-Dreieck, drei halb so große Kopien seiner selbst.
Warum es funktioniert
Wähle zufällig eine der drei Ecken eines Dreiecks und spring auf halbem Weg zu ihr. Markiere die Stelle und wiederhole das. Die Sprünge sind reiner Zufall, und doch erscheint nach ein paar Tausend von ihnen das Sierpiński-Dreieck: ein Dreieck, aus dem Dreiecke ausgeschnitten sind, in jeder Größenordnung.
xₖ₊₁ = xₖ + r · (Ecke − xₖ)Dreieck: r = 1/2Fünfeck: r ≈ 0,618Sechseck: r = 2/3
Bau es selbst
Python 3 · numpy · matplotlib60.000 zufällige Sprünge auf halbem Weg zu einer Ecke, eingefärbt nach der Ecke.
"""Chaos game: jump a part r of the way to a random corner of a polygon, again and again.
Run: python chaos-game.py (needs: pip install numpy matplotlib)
"""
import numpy as np
import matplotlib.pyplot as plt
plt.style.use("dark_background")
corners, r, no_repeat = 3, 0.5, False # triangle, halfway: the Sierpinski triangle
steps = 60000
rng = np.random.default_rng()
angles = np.pi / 2 + 2 * np.pi * np.arange(corners) / corners
vertex = np.column_stack([np.cos(angles), np.sin(angles)])
points, chosen = np.zeros((steps, 2)), np.zeros(steps, dtype=int)
x, last = np.array([0.0, 0.0]), -1
for i in range(steps):
c = rng.integers(corners)
while no_repeat and c == last: # the restricted game: never the same corner twice
c = rng.integers(corners)
x = x + r * (vertex[c] - x) # the whole rule
points[i], chosen[i], last = x, c, c
plt.figure(figsize=(6, 6))
plt.scatter(points[20:, 0], points[20:, 1], s=0.3, c=chosen[20:], cmap="rainbow")
plt.axis("equal")
plt.axis("off")
plt.show()
# Try: corners, r = 5, 0.618 (a pentagon) or corners, no_repeat = 4, True (a square, restricted)
Probier: Setze corners = 5 und r = 0.618, oder corners = 4 mit no_repeat = True.
Lerne dieses Skript Zeile für Zeile, mit Übungen und einem Quiz → · starte es in Google Colab (auf Englisch) →
Für Lehrkräfte: ein Stundenentwurf für 45 Minuten und ein Arbeitsblatt auf drei Niveaus →
Die Mathematik, wie der Film sie erzählt
Die Notizen zum Film lesen (von YouTube, auf Englisch)
Start anywhere. Pick one of the triangle's three corners at random and jump exactly halfway toward it. Plot the point.
Repeat. Nothing about the choices is planned — a coin, a die, pure chance — and yet after a few thousand jumps the Sierpiński triangle appears, sharp and complete. The reason is that "jump halfway to a corner" is a contraction: it shrinks every distance by half, so wherever the point starts, after a handful of jumps it is pulled onto the one shape that the three half-size copies of itself map back onto — the fractal is the only set the rule leaves unchanged.
Each point here is coloured by the corner it just jumped toward, which is why order seems to grow out of rainbow noise. From the triangle on, only the rule changes: a pentagon with a golden jump of 0.618, a pentagon where the same corner may never be chosen twice in a row, a square where the opposite corner is forbidden, a hexagon with a two-thirds jump. Every new shape is born from the cloud of the previous one, because the walkers simply keep going under the new rule.
Nothing is drawn; everything is counted.
Aus der Beschreibung von Pure Randomness Draws a Perfect Fractal (auf Englisch).