Log inStart free
LESSON 2.20 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Pseudorandom generators and seeds

Watch one seed and one fixed rule make every random number.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 2.20 · GENERATOR BAYSEED 8 · STATE x₀ = 8
01
Stage 1 of 6 · Seed the state
A pseudorandom number generator keeps one state. The seed 8 sets it.
Explain it simply

A computer can't flip a real coin. So it keeps one number, called its state, and changes it with a fixed rule. The seed is the state you start from. Here the seed is 8, so dot 8 on the ring lights up.

A ring of 16 states, 0 to 15. The seed 8 marks the first state.

state xseed, rule stepdraw u, walker pathrepeated stepstate never reached
generatordrawshistogram of usimulator: walker, draw 1 → 8x ← (5x + 1) mod 16x₀ = seed = 8seed01234567891011121314150.25.5.7510generatordrawshistogram of usimulator: walker, draw 1 → 8x ← (5x + 1) mod 16x₀ = seed = 8seed01234567891011121314150.25.5.7510
Toy: a 16-state generator x ← (a·x + c) mod 16 · 8 draws per run · a walker on a line
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
x0=seed\sy{x}{data}{x_0} = \sy{seed}{param}{\text{seed}}
x0=8x_0 = 8

The seed is the first state.

Common mix-ups

MYTHA pseudorandom generator makes numbers that nobody can predict.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With a = 3, does the state visit all 16 values before it repeats?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.