Guide

How Random Number Generators Work

Updated · 2 min read

A plain-English explanation of pseudorandom and true random number generators, seeds, and how a generator turns raw bits into a number in your range.

On this page

A random number generator (RNG) produces numbers that are hard to predict. Most of the generators you use on a computer are pseudorandom: a mathematical process, not a roll of physical dice. Understanding the difference helps you choose the right tool for a job.

Two families of generators

  • Pseudorandom number generators (PRNGs) start from a hidden starting value, called a seed, and apply a formula again and again. The same seed always produces the same sequence.
  • Hardware or “true” random number generators (TRNGs) measure a physical process such as electrical noise. Their output cannot be replayed. See hardware random number generators.

From random bits to a number in your range

A generator first produces random bits, for example a 32-bit whole number. Turning that into “a number from 1 to 10” needs care. The tempting method is to take the remainder after dividing by 10, but that makes some results slightly more likely when the number of possible bit patterns does not divide evenly. This is called modulo bias.

The fair method is rejection sampling: discard any raw value that falls in the uneven leftover part, and draw again. ToolMuti’s random number generator uses this approach so each value in your range has exactly the same chance.

Drawing without repeats

To pick several different numbers, a generator can shuffle the whole range (the Fisher–Yates shuffle) and take the first few, like drawing numbered tickets from a hat. You can try it with the no-repeats generator. Asking for more unique numbers than the range contains is impossible, which is why a tool must reject such a request.

What your browser provides

Modern browsers expose crypto.getRandomValues(), which is designed to give unpredictable values suitable for security work. Every ToolMuti tool uses it, from the random password generator to the number wheel and the random name picker. It is cryptographically secure pseudorandomness, which is excellent for games, giveaways and passwords, but it is not a quantum or dedicated hardware device. For the full distinction read pseudorandom and cryptographically secure randomness.

Key points

  • Random does not mean evenly spread: short sequences can contain streaks and repeats.
  • A fair generator gives every allowed value the same probability.
  • A seed lets you repeat a sequence on purpose; see what is a random seed.

Try the tools

More guides