RandomInteger
A uniform random integer, or a list (or array) of them -- Random over a Range, by its Wolfram name.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram Language
RandomInteger!RandomInteger() or , each with probability .RandomInteger(max)uniform in .RandomInteger({min, max})uniform in .RandomInteger(range, n)a list of draws from range (either form above).RandomInteger(range, {n1, …, nk})an array of draws.Typed signatures
| Type | Package | Applies |
|---|---|---|
((integer | list<integer>)?, (integer<0..> | list<integer<0..>>)?) random -> integer | list | combinatorics | always |
Details
- Seeded, not free-running: call SeedRandom(seed) first for a reproducible sequence. Without it, a fixed default seed is used, so even a bare
RandomIntegercall is reproducible run to run — two fresh evaluations draw the same value. - The generator is our own (a small deterministic PRNG), not Wolfram's — the same seed draws a different sequence from Wolfram's. Only the shape and range of the answer are guaranteed to match.
- A worked example that both seeds and draws needs the two calls in one expression;
Last(List(SeedRandom(n), RandomInteger(…)))runsSeedRandomfor its effect and keeps the draw.
Examples
Basic #
42 is the fixed default seed a bare RandomInteger call (no SeedRandom) also uses — reseeded explicitly here so the example stays reproducible regardless of whatever else has already drawn from this engine's shared stream (e.g. another head's own reference example, run earlier on the same worker — see RandomGraph)
live ↗InOut
Scope #
About
| Examples | 4 |
|---|---|
| Checked against | Wolfram Language 2 agree2 differ |
| Crosswalk | Wolfram Language |
See also: SeedRandom