An interactive OJS playground demonstrating a linear congruential generator (LCG) using the formula X_n = (aX_{n-1} + c) mod m. Controls on the left set modulus (m=8), multiplier (a=5), increment (c=3), seed (X_0=1), and numbers to generate (12). A table on the right shows the resulting sequence of X values, intermediate calculations, mod m results, and normalized values X_n/m, with the final "random" numbers highlighted in yellow.
Excerpt from the blog post with R code that tests all seeds from 1 to 10,000 to find which ones produce 10 heads in a row when simulating coin flips. The possible_seeds data frame is filtered to show 10 seeds (614, 1667, 3212, 4166, 4580, 5527, 5824, 7365, 7468, 8975) that meet this criterion. The post notes that seed 614 actually produces 13 heads in a row, confirmed with a withr::with_seed(614, ...) call below.
R console output demonstrating that set.seed(1234) produces reproducible results. The first block calls runif(5) and returns five values: 0.1137, 0.6223, 0.6093, 0.6234, 0.8609. The second block uses the same seed but splits the draw into runif(2) then runif(3), returning the same five values in the same order, showing that the sequence is preserved regardless of how many numbers are drawn at a time.
Table of contents for the post: Introduction Seeds and reproducible randomness My (somewhat incorrect) mental model of how seeds work Making “random” numbers with an equation Live interactive playground Cycles and fancier algorithms Why does it matter if “random” numbers aren’t actually random? You’re limiting yourself to narrow, known universes You can seed hack and get any values you want Real world bad things can happen because of pseudorandom numbers Can computers even create true randomness? Moving a mouse around Lava lamps Atmospheric noise How I use true randomness in my own work “…as an ook cometh of a litel spyr…”
I've been using random seeds for years but I have no idea how they work. Seeds somehow(?) make the same random numbers?
So I figured it out! New post includes an interactive PRNG generator, lava lamps, lottery fraud, @random.org, Chaucer, and Minecraft #rstats
www.andrewheiss.com/blog/2026/04...