# 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**.

النسخة التفاعلية: https://www.calcopenly.com/ar/statistics/random-number-generator
الموضوع: حاسبات الإحصاء والاحتمالات

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.

## المدخلات

- **Generate** (الخيارات: Integers, Decimals, Dice rolls)
- **من**
- **إلى**
- **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.

## النتائج

- النتائج — النتيجة الرئيسية
- Sum
- Mean
- Smallest
- Largest

## الصيغة

$$
\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}
$$

## أمثلة محلولة

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

- Generate: Integers
- من: 1
- إلى: 100
- How many: 10
- Seed: 2026
- **النتائج: 10, 13, 19, 87, 95, 37, 73, 40, 32, 34**
- **Sum: 440**
- **Smallest: 10**
- **Largest: 95**
- مصدر التحقق: ⁨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
- من: 1
- إلى: 49
- How many: 6
- No repeats: نعم
- Sort the results: نعم
- Seed: 2026
- **النتائج: 11, 12, 18, 37, 40, 45**
- **Sum: 163**
- مصدر التحقق: ⁨Same Python reference implementation⁩

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

- Generate: Decimals
- من: 0
- إلى: 1
- How many: 5
- Decimal places: 3
- Seed: 2026
- **النتائج: 0.683, 0.143, 0.793, 0.253, 0.375**
- **Sum: 2.247**
- مصدر التحقق: ⁨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
- **النتائج: 1, 6, 1**
- **Sum: 8**
- مصدر التحقق: ⁨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
- من: 1
- إلى: 1
- How many: 3
- Seed: 7
- **النتائج: 1, 1, 1**
- **Sum: 3**
- مصدر التحقق: ⁨With m = 1 every draw maps to the minimum⁩

### Edge case: all 5 values without repeats

- Generate: Integers
- من: 1
- إلى: 5
- How many: 5
- No repeats: نعم
- Seed: 2026
- **النتائج: 5, 3, 4, 2, 1**
- **Sum: 15**
- مصدر التحقق: ⁨Python reference: a full permutation of 1–5⁩

## الأسئلة

### 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.

### ما مدى دقة «⁨Random number generator (seeded)⁩»؟

تعتمد الدقة على مدخلاتك وافتراضات الطريقة. يستخدم الحساب العشري 50 رقمًا معنويًا، لكن التقديرات والأساليب العددية وبيانات المصدر قد تكون أقل دقة؛ تقريب القيم المعروضة لا يزيل هذه الحدود. أمثلة محلولة جرى التحقق منها بمصادر مستقلة: 6. مثلًا، يجري التحقق من «⁨Ten integers 1–100, seed 2026 (defaults)⁩» بالرجوع إلى ⁨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)⁩.

### ما مصدر هذه الطريقة؟

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).

## المصادر

- [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)
