Home/Randomization, Games & Decision Tools/Random Number Generator & Range Picker

Random Number Generator & Range Picker

Generate cryptographically secure random numbers with custom bounds, non-repeating options, sorting, and statistical batch analyses.

Range & Batch Parameters

Web Crypto EntropyRejection Sampling Enabled

Output Results & Log

No Numbers Generated Yet

Configure your min/max bounds and click Generate.

Cryptographic Randomness vs. Pseudo-Random Number Generators (PRNGs)

In standard web applications, random numbers are generated using deterministic software routines like JavaScript's native Math.random(). These standard engines are classified as Pseudo-Random Number Generators (PRNGs). While fast, PRNGs rely on mathematical formulas initialized by an internal state seed (typically the system microsecond clock). Given knowledge of the seed or a sufficiently long output sequence, future values can be predicted with 100% mathematical certainty.

Standard PRNG (Math.random)

Uses deterministic algorithms (e.g., xorshift128+ in V8). Suitable for casual animations, but vulnerable to pattern analysis and period repetition over large sample iterations.

CSPRNG (Web Crypto API)

Leverages hardware entropy (e.g., thermal noise, CPU timing jitter). Provides true cryptographic unpredictability, ensuring every integer in your chosen range has an identical theoretical probability.

Eliminating Modulo Bias via Rejection Sampling

A common flaw in custom range generators is naive modulo arithmetic: mapping a raw 32-bit unsigned integer $R \in [0, 2^32-1]$ to a target range $[0, M-1]$ using $R \pmod M$. When the total state space $2^32$ is not evenly divisible by $M$, lower numbers in the range receive a subtly higher statistical probability of selection—a flaw known as modulo bias.

To eliminate modulo bias entirely, our generator implements rejection sampling. The engine establishes an exact threshold cutoff $T$:

T = floor(2^32 / rangeSize) * rangeSize

Any randomly drawn byte sequence evaluating to a value equal to or greater than $T$ is discarded immediately, and a fresh draw is executed. This guarantees absolute mathematical uniformity across every selected bound.

Theoretical Probability Reference Matrix

Range Span ($N$)Single Pick Odds ($1/N$)Probability %Entropy (Bits)
1 to 2 (Binary)1 in 250.00%1.00 bit
1 to 6 (Standard Die)1 in 616.67%2.58 bits
1 to 10 (Decile)1 in 1010.00%3.32 bits
1 to 100 (Percentage)1 in 1001.00%6.64 bits
1 to 1,0001 in 1,0000.10%9.97 bits

Practical Use Cases & Application Workflows

Raffles & Sweepstakes

Select unique non-repeating winning ticket numbers from a ticket range (e.g., 1 to 5,000) with complete cryptographic auditability.

Data Sampling & Testing

Extract unbiased randomized database row IDs or sample subsets for statistical validation without sorting bias.

Classroom & Group Pickers

Assign student numbers, tournament seeds, or order sequences fairly without manual paper draws.

Frequently Asked Questions (FAQ)

How does this random number generator guarantee true randomness?

This application utilizes the Web Crypto API (crypto.getRandomValues) rather than standard Math.random(). By retrieving raw hardware entropy from your browser, it eliminates algorithmic predictability and guarantees true uniform distribution across specified bounds.

Can I generate unique random numbers with no duplicates?

Yes. By unchecking the "Allow Duplicates" setting, the algorithm enforces set uniqueness across generated values, provided the total requested count does not exceed the total available integers in the selected range.

What is modulo bias in random number generation?

Modulo bias occurs when mapping a binary random integer range (e.g., 0 to $2^32-1$) to a target interval using simple modulus arithmetic when the range length is not a power of two. Our generator implements rejection sampling to completely eliminate modulo bias.

Is there a limit on how many numbers I can generate at once?

You can generate up to 10,000 random numbers in a single batch directly inside your local browser memory thread instantly.

How are custom delimiters formatted for export?

You can format your generated number sets using commas, spaces, line breaks (newlines), or tab characters for instant copy-pasting into spreadsheets or CSV documents.

Found this tool helpful? Share it with others!

Share on Facebook
Share on X
Share on LinkedIn
Copy URL

Related & Complementary Utilities

Explore more privacy-first client-side web tools.