Random Number Generator: Seeded Range Formula & Examples
Short answer
A random number generator produces discrete, uniformly distributed integers between a specified minimum and maximum value using a deterministic pseudo-random seed. With a range of 1 to 100, a count of 5, and seed 42, the tool generates 61, 45, 86, 67, and 18, which sum to 277. Using the same seed guarantees identical, verifiable results every time.
Formula
X = a + floor(R × (b - a + 1)), where a = ceil(min(lo, hi)), b = floor(max(lo, hi)), and R ∈ [0, 1)
X is the generated random integer within the closed interval [a, b]. 'lo' and 'hi' are the user-provided bounds. 'a' is the lower integer boundary calculated by taking the ceiling of the minimum input. 'b' is the upper integer boundary calculated by taking the floor of the maximum input. 'R' is a standard uniform pseudo-random decimal strictly greater than or equal to 0 and strictly less than 1, generated from the numeric seed. 'floor' rounds down to the nearest integer.
Worked example
- Minimum
- 1
- Maximum
- 100
- How many numbers
- 5
- Seed (change for new numbers)
- 42
- Random numbers: 61, 45, 86, 67, 18
- Sum: 277
What It Calculates and Who It's For
A random number generator produces discrete, uniformly distributed integers across a chosen numerical range. Unlike physical random processes, such as rolling dice or measuring atmospheric noise, digital generators typically use a pseudo-random number generator (PRNG). A PRNG processes an initial numerical input—known as a seed—through an algebraic formula to return a deterministic sequence of digits that mimics true randomness.
This calculator is designed for students, researchers, data analysts, educators, and developers who need:
- Quick sample sets for classroom demonstrations and probability exercises.
- Unbiased integer selection for raffles, board games, or priority lists.
- Replicable simulation data where maintaining the exact same results via a documented seed is essential for peer verification or debugging.
Each generated number is chosen independently from the closed interval [Minimum, Maximum]. That means every whole number in the span has an identical chance of being picked on every draw.
Step-by-Step Worked Example
To understand how the algorithm translates inputs into output values, consider the following baseline parameters:
- Minimum (lo): 1
- Maximum (hi): 100
- Count (k): 5
- Seed: 42
Step 1: Establish Valid Integer Bounds
The formula checks the inputs to define bounds a and b:
$$
a = \lceil \min(1, 100) \rceil = 1
$$
$$
b = \lfloor \max(1, 100) \rfloor = 100
$$
The span of possible whole numbers is:
$$
b - a + 1 = 100 - 1 + 1 = 100
$$
Step 2: Generate Uniform Floating-Point Values
The PRNG uses the seed 42 to produce a sequence of deterministic decimal fractions strictly between 0 and 1 ($R \in [0, 1)$). Suppose the internal generator produces the following initial five fractions:
- $R_1 \approx 0.6015$
- $R_2 \approx 0.4431$
- $R_3 \approx 0.8522$
- $R_4 \approx 0.6689$
- $R_5 \approx 0.1740$
Step 3: Scale and Shift to the Target Interval
Each random fraction is multiplied by the span (100), floored to drop the decimal, and offset by the minimum ($a = 1$): $$ X_1 = 1 + \lfloor 0.6015 \times 100 \rfloor = 1 + 60 = 61 $$ $$ X_2 = 1 + \lfloor 0.4431 \times 100 \rfloor = 1 + 44 = 45 $$ $$ X_3 = 1 + \lfloor 0.8522 \times 100 \rfloor = 1 + 85 = 86 $$ $$ X_4 = 1 + \lfloor 0.6689 \times 100 \rfloor = 1 + 66 = 67 $$ $$ X_5 = 1 + \lfloor 0.1740 \times 100 \rfloor = 1 + 17 = 18 $$
Output List: 61, 45, 86, 67, 18
Sum: $61 + 45 + 86 + 67 + 18 = 277$
How to Read and Evaluate the Results
When evaluating a set of random numbers, observe these standard statistical benchmarks:
- Expected Mean: For a discrete uniform distribution, the theoretical mean is $(a + b) / 2$. For a range of 1 to 100, the expected mean is $50.5$. In our sample, the sample mean is $277 / 5 = 55.4$, which is well within expected variance for a small sample size ($k = 5$).
- Independent Draws (With Replacement): Because selections are independent, observing a duplicate number (e.g., getting 45 twice in a larger batch) is normal and mathematically expected under the birthday paradox principles.
- Seed Determinism: If you share the parameters
lo=1,hi=100,k=5, andseed=42, anyone using this algorithm receives the exact sequence61, 45, 86, 67, 18. Changing the seed to any other value instantly yields an entirely different set of numbers.
Practical Tips for Best Results
- Vary the Seed for New Draws: If you want a fresh draw, increment or alter the seed field (e.g., set it to today's date or current time).
- Double-Check Range Width: If you draw 50 numbers from a narrow range (such as 1 to 5), you will receive many duplicate values. Expand the range if high uniqueness is preferred.
- Preserve Seed Data for Audits: If you run a drawing or select items for review, take a screenshot or record the seed. This allows any participant to verify that the selection was computed fairly without cherry-picking.
When Not to Rely on This Calculator
While ideal for general-purpose math, classroom lessons, and quick random selections, seeded pseudo-random generators have strict limitations:
- Cryptography and Authentication: Do not use this tool to generate password reset tokens, encryption salts, or private API keys. PRNG sequences can be reverse-engineered if the underlying state is discovered.
- Official Lotteries or Gaming Compliance: Commercial gaming and legal prize drawings mandate hardware-based true random number generators (TRNGs) certified by regulatory authorities.
- Sampling Without Replacement: If you require a strictly unique list (such as shuffling a 52-card deck), this tool does not guarantee uniqueness because each draw is processed independently.
Comparison
| Scenario | Input | Result |
|---|---|---|
| Lower input | Minimum: 0.8 | Random numbers: 61, 45, 86, 67, 18 |
| Base example | Minimum: 1 | Random numbers: 61, 45, 86, 67, 18 |
| Higher input | Minimum: 1.2 | Random numbers: 61, 46, 86, 68, 19 |
Common mistakes
- Assuming uniform random generation prevents duplicates (sampling occurs with replacement).
- Using non-cryptographic pseudo-random generators for passwords, encryption keys, or regulated gaming.
- Entering non-integer bounds without realizing the formula rounds the minimum up and the maximum down to preserve integer boundaries.
- Forgetting to document the seed value when conducting scientific simulations or classroom audits that require exact replication.
- Believing past outcomes influence upcoming numbers (the gambler's fallacy).
Checklist
- Define clear inclusive minimum and maximum limits for your range.
- Choose how many integers you need (up to 50 values per batch).
- Record your seed value if you need to reproduce or audit your results later.
- Change the seed to generate an entirely new sequence of numbers.
- Verify whether your application permits duplicate values, as uniform sampling with replacement can repeat numbers.
- Ensure non-cryptographic pseudo-random numbers are acceptable for your specific use case.
Calculators Percentage Editorial Team
Calculator guides from the Calculators Percentage team. These introductory examples are educational, not professional advice.
Last reviewed:
This utility utilizes a seeded pseudo-random algorithm for modeling, education, and general utility. It is not intended for cryptographic security, sensitive authentication, or regulated gambling systems.
