# Random number generator (seeded)

> Generate random numbers from a seed: integers in a range, decimals, lottery-style draws without repeats and dice rolls, repeatable with xoshiro256**.

Interactive version: https://www.calcopenly.com/statistics/random-number-generator
Subject: Statistics and probability calculators

Numbers come from xoshiro256**, a 64-bit pseudorandom generator by Blackman and Vigna with a period of 2²⁵⁶ − 1, whose starting state is filled from your seed by SplitMix64. Each 64-bit output x becomes min + (x mod m), where m is the number of possible values, after outputs from the top sliver of the 64-bit range are thrown away so that every value is exactly equally likely. Decimals are drawn as whole numbers of 10⁻ᵈ steps and divided back.

The default draws 10 integers from 1 to 100 with seed 2026: 10, 13, 19, 87, 95, 37, 73, 40, 32, 34. Anyone who enters the same seed and settings gets the same list, so raffle draws, classroom samples and simulations can be checked afterwards.

A seed-driven list is predictable to anyone who knows or guesses the seed, so it is unsuitable for passwords, encryption keys or prize draws where the seed is not published in advance.

## Inputs

- **Generate** (options: Integers, Decimals, Dice rolls)
- **From**
- **To**
- **How many**
- **Decimal places**
- **No repeats**: Draw without replacement, like lottery numbers.
- **Sort the results**
- **Number of dice**
- **Sides per die**
- **Seed**: Same seed, same numbers. Change it for a new draw. A fresh unseeded draw from the browser's secure random source is not part of this calculation.

## Results

- Results — main result
- Sum
- Mean
- Smallest
- Largest

## Formula

$$
\begin{gathered} v = \text{min} + (x \bmod m),\quad m = \text{max} - \text{min} + 1 \\ \text{keeping only } x < \left\lfloor 2^{64}/m \right\rfloor m \end{gathered}
$$

## Worked examples

### Ten integers 1–100, seed 2026 (defaults)

- Generate: Integers
- From: 1
- To: 100
- How many: 10
- Seed: 2026
- **Results: 10, 13, 19, 87, 95, 37, 73, 40, 32, 34**
- **Sum: 440**
- **Smallest: 10**
- **Largest: 95**
- Checked against: Independent Python transcription of Vigna's splitmix64.c and xoshiro256starstar.c with the same rejection mapping (scratch script; its SplitMix64 matches the published seed-0 value 0xE220A8397B1DCDAF)

### Lottery: 6 of 49, no repeats, sorted

- Generate: Integers
- From: 1
- To: 49
- How many: 6
- No repeats: yes
- Sort the results: yes
- Seed: 2026
- **Results: 11, 12, 18, 37, 40, 45**
- **Sum: 163**
- Checked against: Same Python reference implementation

### Five decimals in [0, 1] to 3 places

- Generate: Decimals
- From: 0
- To: 1
- How many: 5
- Decimal places: 3
- Seed: 2026
- **Results: 0.683, 0.143, 0.793, 0.253, 0.375**
- **Sum: 2.247**
- Checked against: Same Python reference implementation (integer draw in [0, 1000], divided by 10³)

### 3d6 with a text seed

- Generate: Dice rolls
- Number of dice: 3
- Sides per die: 6
- Seed: hello
- **Results: 1, 6, 1**
- **Sum: 8**
- Checked against: Python reference; the text seed hashes to FNV-1a 64 0xa430d84680aabd0b, the published FNV-1a hash of “hello”

### Edge case: a range of one value

- Generate: Integers
- From: 1
- To: 1
- How many: 3
- Seed: 7
- **Results: 1, 1, 1**
- **Sum: 3**
- Checked against: With m = 1 every draw maps to the minimum

### Edge case: all 5 values without repeats

- Generate: Integers
- From: 1
- To: 5
- How many: 5
- No repeats: yes
- Seed: 2026
- **Results: 5, 3, 4, 2, 1**
- **Sum: 15**
- Checked against: Python reference: a full permutation of 1–5

## Questions

### Are these random numbers truly random?

No, they are pseudorandom: a fixed calculation turns the seed into a sequence that looks random but repeats exactly for the same seed. That suits games, sampling and simulation. Passwords and keys need a cryptographically secure generator, such as the browser's crypto.getRandomValues or a deterministic random bit generator specified in NIST SP 800-90A, which an observer cannot predict from past outputs.

### What does the seed do?

The seed sets the generator's starting state, so the same seed and settings always give the same numbers on any device. A whole-number seed from 0 to 18,446,744,073,709,551,615 (2⁶⁴ − 1) is used directly; any other text is hashed with 64-bit FNV-1a. For example, 3 six-sided dice with the seed hello always roll 1, 6, 1.

### How do I draw lottery numbers without repeats?

Set the range to 1–49, How many to 6 and turn on No repeats; a duplicate is redrawn until 6 different numbers remain. Each of the C(49, 6) = 13,983,816 possible sets is equally likely, including 1, 2, 3, 4, 5, 6. Turn on Sort the results to list them in order, as lottery tickets do.

### Why not just take the generator's output modulo the range?

Because the plain remainder favours some values whenever the range doesn't divide the number of possible outputs. A toy generator with 8 outputs (0–7) mapped to 3 values by x mod 3 gives remainders 0, 1, 2, 0, 1, 2, 0, 1, so two values get 3/8 and one gets 2/8. Rejecting outputs 6 and 7 makes each value exactly 1/3; this calculator applies the same rule to its 2⁶⁴ outputs.

### How accurate is the random number generator?

Accuracy depends on your inputs and the method's assumptions. Decimal arithmetic uses 50 significant digits, but estimates, numerical methods and source data can be less precise; the displayed rounding does not remove those limits. It is checked against 6 worked examples whose answers come from independent sources; for example, “Ten integers 1–100, seed 2026 (defaults)” is checked against Independent Python transcription of Vigna's splitmix64.c and xoshiro256starstar.c with the same rejection mapping (scratch script; its SplitMix64 matches the published seed-0 value 0xE220A8397B1DCDAF).

### Where does the method come from?

Blackman & Vigna, Scrambled linear pseudorandom number generators (xoshiro256**), ACM TOMS 47(4), 2021; Steele, Lea & Flood, Fast splittable pseudorandom number generators (SplitMix64), OOPSLA 2014; Fowler–Noll–Vo hash, FNV-1a 64-bit parameters (IETF draft-eastlake-fnv).

## Sources

- [Blackman & Vigna, Scrambled linear pseudorandom number generators (xoshiro256**), ACM TOMS 47(4), 2021](https://prng.di.unimi.it/)
- Steele, Lea & Flood, Fast splittable pseudorandom number generators (SplitMix64), OOPSLA 2014
- [Fowler–Noll–Vo hash, FNV-1a 64-bit parameters (IETF draft-eastlake-fnv)](https://datatracker.ietf.org/doc/html/draft-eastlake-fnv)
