# Random Number Generator

URL: https://speedycalculator.com/calculators/statistics/random-number/
Last updated: 2026-10-30

> The random number generator produces one or many random numbers between a minimum and a maximum – whole numbers or decimals, with or without repeats, with the endpoints included or excluded, sorted or in draw order – using your browser's cryptographically secure randomness.

## Inputs

- Generate
- Minimum value
- Maximum value
- How many numbers
- Type of number
- Decimal places
- Include the minimum and maximum?
- Duplicates
- Order

## Results

- Your random number
- Your random numbers
- Sum
- Mean
- Smallest
- Largest
- Possible values
- Spread of the numbers

## Formula

```
Integer in [a, b]: a + ⌊u × (b − a + 1)⌋ with u uniform on [0, 1) · decimal with d places: a + ⌊u × ((b − a)·10ᵈ + 1)⌋ ÷ 10ᵈ
```

## Explanation

Random numbers are needed for draws, raffles, games, picking a sample for a survey, assigning people to groups and countless classroom exercises. A good generator gives every allowed value exactly the same chance and makes each number independent of the others. This tool uses crypto.getRandomValues(), the secure generator built into modern browsers, rather than the simpler Math.random(), so the numbers are suitable even for prize draws.

Generate a single number, or a list of up to 10,000. Choose whole numbers or decimals with up to ten decimal places, decide whether the minimum and maximum themselves may appear, and switch duplicates off when every number must be different – as when drawing raffle tickets or lottery numbers. You can sort the list in ascending or descending order or keep it in the order drawn.

Alongside the numbers you get their sum, mean, smallest and largest value and the number of distinct values that were possible, and for longer lists a histogram that shows how evenly the numbers spread across the range.

### How to use the Random Number Generator

- **Generate**
- **Minimum value**
- **Maximum value**
- **How many numbers**
- **Type of number**
- **Decimal places**
- **Include the minimum and maximum?**
- **Duplicates**
- **Order**

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

### How it works

The generator maps the allowed values onto a grid with the chosen number of decimal places, removes excluded endpoints and draws uniformly from the grid. Without duplicates it uses a partial Fisher–Yates shuffle (for dense draws) or rejection of repeats (for sparse draws), so every set of distinct numbers is equally likely.

### Worked example

Drawing 6 different numbers from 1 to 49 is the same as a 6/49 lottery draw: there are C(49, 6) = 13,983,816 possible sets, each equally likely. A single whole number from 1 to 100 has 100 possible values, so each has a 1% chance; excluding both endpoints leaves 98 values (2 to 99).

### When to use which setting

TaskRangeSettingsRoll a die1 – 6Single whole numberPick 3 raffle winners from 250 tickets1 – 2503 numbers, no repeatsRandom percentage0 – 100Decimals, 1 placeShuffle a class of 30 into order1 – 3030 numbers, no repeats, in draw order

## Worked example

Inputs — Generate: A single number; Minimum value: 1; Maximum value: 100; Type of number: Whole numbers (integers); Include the minimum and maximum?: Include both.

Results — **Your random number = 94**; Your random numbers = 94; Sum = 94; Mean = 94; Smallest = 94; Largest = 94.

## Key terms

- **Uniform distribution**: Every allowed value has the same probability.
- **Pseudorandom number generator (PRNG)**: An algorithm that produces numbers that look random from a secret starting value (seed).
- **Sampling without replacement**: Drawing values so that each can appear only once.

## FAQ

**Is this random number generator truly random?**
It uses the browser's cryptographically secure pseudorandom generator, which is seeded from hardware noise and is unpredictable in practice. "True" random generators read physical processes directly, but for draws and games the difference does not matter.

**How do I pick a random number between 1 and 10?**
Set the minimum to 1 and the maximum to 10 with whole numbers; each value has a 10% chance.

**How do I generate numbers without repeats?**
Choose "Several numbers" and "No repeats". You can draw at most as many numbers as there are possible values.

**How do I make a random 4-digit code?**
Use 0 to 9999 and pad with zeros, or 1000 to 9999 if the first digit must not be zero (9,000 possible codes).

**Can I generate random decimals?**
Yes – choose decimals and the number of decimal places, e.g. 0 to 1 with 3 places gives values like 0.593.

**Why do I get the same number twice in a short list?**
With repeats allowed it is normal: drawing 10 numbers from 1–100 contains a repeat 37% of the time (the birthday effect).

**Can I use it for a raffle?**
Yes. Number the tickets, set the range and draw the required number of winners without repeats.


## Sources

- [MDN – Crypto.getRandomValues()](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues)
- [RANDOM.ORG – Introduction to randomness and random numbers](https://www.random.org/randomness/)
- [NIST/SEMATECH e-Handbook of Statistical Methods](https://www.itl.nist.gov/div898/handbook/)
