Random Number Generator

Generate high-quality random integers or decimals tailored to your needs. This tool serves developers, analysts, teachers, and decision-makers who require either cryptographically strong unpredictability or reproducible sequences via a seed. Avoid duplicates, exclude values, sort results, and export — all in your browser.

Data Source and Methodology

  • NIST SP 800-90A Rev. 1 — Recommendation for Random Number Generation Using Deterministic Random Bit Generators (2015). Official document.
  • RFC 4086 — Randomness Requirements for Security (2005). RFC text.
  • W3C Web Crypto API (Candidate Recommendation). Specification.

Tutti i calcoli si basano rigorosamente sulle formule e sui dati forniti da questa fonte.

This tool uses the Web Crypto API for cryptographic randomness and a high-quality deterministic PRNG (Mulberry32 with FNV-1a seeding) for reproducible sequences. Integer sampling avoids modulo bias via rejection sampling. Decimals are produced by scaling a uniform U ∈ [0,1) to your chosen range and rounding to the selected precision.

The Formula Explained

Integer mapping (inclusive bounds):
\( n = \lfloor U \cdot (b - a + 1) \rfloor + a \), where \( U \sim \mathrm{Uniform}[0,1) \), \( a = \text{min} \), \( b = \text{max} \).

Rejection sampling to avoid modulo bias using 32-bit unsigned integers:
Let \( R = b - a + 1 \), \( M = 2^{32} \), \( T = \left\lfloor \frac{M}{R} \right\rfloor \cdot R - 1 \). Draw \( X \sim \{0,\dots,M-1\} \) until \( X \le T \). Then output \( a + (X \bmod R) \).

Decimal mapping with d decimal places:
\( x = a + U \cdot (b - a) \), then \( y = \mathrm{round}(x, d) \).

Glossary of Variables

  • Number type: Integer or Decimal output.
  • Min (a): Lower bound of the range.
  • Max (b): Upper bound of the range.
  • Include min/max: Whether a and/or b are part of the set.
  • Decimal places (d): Digits after the decimal point for decimal mode.
  • Quantity (N): How many values to generate (1–10,000).
  • No repeats (unique): Prevent duplicate values in the output.
  • Exclude list: Values to omit (comma-separated).
  • Randomness source: Cryptographically secure (Web Crypto API) or Seeded (deterministic).
  • Seed: Any text that determines the reproducible sequence in seeded mode.
  • Sort: Display order (original, ascending, descending).

How it works: A Step-by-Step Example

Suppose you need five unique integers between 1 and 50 for a prize draw. Set Number type = Integer, Min = 1, Max = 50, keep both include toggles on, Quantity = 5, and enable No repeats (unique). Choose Cryptographically secure as the source and press Generate.

The tool samples a 32-bit unsigned integer \( X \) from the Web Crypto API, applies rejection sampling to eliminate modulo bias, and maps the result to \( [1,50] \) using \( n = \lfloor U \cdot 50 \rfloor + 1 \). It repeats until five distinct values are collected. If you select Seeded with a seed like “summer-fair-2025”, the same settings will reproduce the same sequence on every run.

Frequently Asked Questions (FAQ)

Is cryptographic randomness always better?

It’s better for unpredictability and fairness. If you need reproducibility for testing or teaching, choose Seeded.

How do you handle inclusive vs. exclusive bounds?

We adjust the effective range by adding or subtracting one step at the edges. For integers, that step is 1; for decimals, it is 10−d.

Can I exclude values?

Yes. Provide a comma-separated list. The tool validates that your requested quantity is feasible after exclusions.

What’s the maximum precision for decimals?

Up to 10 decimal places. Higher precision increases the number of possible unique values.

Do you store my seeds or results?

No. Everything runs locally in your browser and is not transmitted.

Why do I sometimes see an error with “unique”?

When the quantity exceeds the number of available distinct values in your range (after inclusions/exclusions), it’s impossible to guarantee uniqueness. Reduce quantity or broaden the range.

How do you prevent bias for integers?

We use rejection sampling with 32-bit draws, ensuring every integer in the target range has equal probability.

Strumento sviluppato da Ugo Candido,. Contenuti verificati da,.
Ultima revisione per l'accuratezza in data: .