Advertisement

Random number generator

Choose a range, sample size and seed. The same settings reproduce the same sample, making this useful for demonstrations and exercises.

Calculator

Change this whole number for a different reproducible sample.

First generated number
6.0000000000
Final generator state
2,007,237,709.000000
Generated numbers
PositionValue
1.00000000006.0000000000
2.00000000008.0000000000
3.00000000002.0000000000
4.00000000007.0000000000
5.00000000009.0000000000
6.00000000001.0000000000
7.00000000003.0000000000
8.00000000007.0000000000
9.00000000002.0000000000
10.00000000008.0000000000

Advertisement

How this calculator works

The seed starts a deterministic Park-Miller sequence. Integers include both endpoints and use rejection mapping so every mapped integer has the same number of accepted generator states. Without-replacement mode skips values already in the sample. Decimal mode maps the finite generator grid into the chosen interval with the upper endpoint excluded. This is a reproducible teaching tool, not a source for cryptographic keys, lottery draws or other security-sensitive randomness. Change the seed for a different sample; reset restores the defaults.

Formula

State_next = (16807 × state) mod 2147483647. U = (state_next - 1)/2147483646. Decimal value = lower + (upper - lower)U. Integer mapping uses accepted states modulo the inclusive range size.

Worked example

With seed 1, integer bounds 0 and 9 and three values, the output is 6, 8, 2. Seed 2 with the same bounds begins 3, 7. These results follow the specified generator and mapping.

Advertisement

Frequently asked questions

Why do results repeat after reset?

Reset restores the seed. Reproducibility is intentional; change the seed to obtain another sequence.

Can I request unique decimal values?

The unique-value control applies to integers only. Decimal samples use the finite generator grid and can repeat over sufficiently long sequences.

Are decimal endpoints included?

The lower endpoint is included in the grid and the upper endpoint is excluded. Integer mode includes both endpoints.

Sources

Advertisement