RandomInteger
RandomInteger[{imin,imax}]
gives a pseudorandom integer in the range {imin,imax}.
RandomInteger[imax]
gives a pseudorandom integer in the range {0,,imax}.
pseudorandomly gives 0 or 1.
RandomInteger[range,n]
gives a list of n pseudorandom integers.
RandomInteger[range,{n1,n2,…}]
gives an n1×n2×… array of pseudorandom integers.
Details
- RandomInteger[{imin,imax}] chooses integers in the range {imin,imax} with equal probability.
- RandomInteger[] gives 0 or 1 with probability .
- RandomInteger gives a different sequence of pseudorandom integers whenever you run the Wolfram Language. You can start with a particular seed using SeedRandom.
- A Method option to SeedRandom can be given to specify the pseudorandom generator used.
Examples
open allclose allBasic Examples (5)
Applications (4)
Properties & Relations (3)
Use SeedRandom to get repeatable random values:
Use BlockRandom to block one use of RandomInteger from affecting others:
RandomInteger generates a uniform distribution, here with mean 5:
Text
Wolfram Research (2007), RandomInteger, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomInteger.html.
CMS
Wolfram Language. 2007. "RandomInteger." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RandomInteger.html.
APA
Wolfram Language. (2007). RandomInteger. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomInteger.html