What a Random Generator Actually Does
A random object generator does three things in order: it narrows the full list to the objects that match your settings, it draws random numbers, and it turns those numbers into picks from the list. Each step has to be right for the result to be fair.
Filtering, drawing random numbers and choosing items are separate steps. A weakness in any of them makes the result unfair.
Where the Randomness Comes From
Computers are deterministic machines, so they produce randomness in one of two ways.
| Aspect | Pseudo-random (PRNG) | Cryptographically secure (CSPRNG) |
|---|---|---|
| How it works | A formula produces a sequence from a starting value called a seed. | Seeded from unpredictable system events, then processed so the output can’t be predicted. |
| Predictable? | Yes, if you know the internal state. | No, not in practice. |
| Example in browsers | Math.random() | crypto.getRandomValues() |
| Good for | Games, simulations, visual effects. | Security, fair draws, anything where trust matters. |
For picking a random object, both kinds give results that look random. The random object generator uses the secure one anyway, because it costs nothing extra and removes any doubt about predictability.
Turning a Number Into a Pick
A random number generator gives you a number in a fixed range — for example, any whole number from 0 to 65,535. You then need a number from 0 to 1,206 to choose one of 1,207 objects. The obvious shortcut is to take the remainder after dividing, but that introduces bias.
Here is the exact effect. 65,536 doesn’t divide evenly by 1,207, so with the remainder method the first 358 objects each correspond to 55 possible values while the other 849 correspond to 54. Those 358 objects would come up 1.85% more often than the rest — forever.
The difference looks tiny, but it is permanent: 358 objects are always favoured. Rejection sampling removes it by discarding the few values that cause the imbalance.
The fix is rejection sampling: if a random value falls in the uneven leftover range at the top, throw it away and draw again. Every remaining value then maps to exactly the same number of objects.
Choosing Several Items: the Fisher–Yates Shuffle
To pick ten objects without repeats, you can’t just draw ten random numbers — you might get the same object twice. The standard solution is the Fisher–Yates shuffle:
- Start with the list of matching objects.
- Pick a random position from the whole list and swap that object into first place.
- Pick a random position from the rest of the list and swap it into second place.
- Repeat until you have as many objects as you need.
Every possible ordering is equally likely, and no object can be chosen twice. Stopping after ten swaps — a partial shuffle — is all the generator needs.
Filters, Pools and No Repeats
Filters don’t change the randomness; they change the pool. If you ask for kitchen objects, the shuffle runs only over kitchen objects, and each one has an equal chance. No repeats keeps a record of what has already been shown and leaves those objects out of the pool until every matching object has appeared once.
How We Check That It Works
Theory is only half the job, so we test the real code. In a 100,000-pick test, every one of our 1,207 objects came up between 58 and 111 times against an expected 82.85, and a chi-square test found no evidence of bias. The full method is in how we tested our generator’s fairness, and you can see the generator in action on the random object generator.
