The rand() command generates a random number. It can be used in one of two ways:
- rand() gives a random real number between 0 and 1.
- rand(n) gives a random integer between 1 and n.
By adding or multiplying appropriately, you can change these bounds. For example, 10rand() gives a random real number between 0 and 10, and rand(9)-5 gives a random number between -4 and 4.
L'Ecuyer's algorithm is used by TI calculators to generate pseudorandom numbers.
:RandSeed 0 :rand() .943597402492 :rand() .908318860975 :rand(10) 2
Using the RandSeed command makes the random numbers entirely predictable: after setting the random seed to some value, the same random numbers will be returned every time.
260 - Domain error happens when the maximum number is 1014 or greater.