Skip to content
Property Value
Hex Value $BB0A
Categories
Localizations
  • FR: entAléat(

randInt(

Overview

Generates and displays a random integer within a range specified by lower and upper integer bounds for a specified number of trials numtrials.

Availability: Token available everywhere.

Syntax

randInt( lower,upper [,numtrials])

Arguments

NameTypeOptional
lower
upper
numtrialsYes

Location

math, PRB, 5:randInt(


Description

randInt(min,max) generates a uniformly-distributed pseudorandom integer between min and max inclusive. randInt(min,max,n) generates a list of n uniformly-distributed pseudorandom integers between min and max.

seed→rand affects the output of randInt(.

0→rand
     0
randInt(1,10)
     10
randInt(1,10,5)
     {10 2 6 5 8}

Optimization

When the lower bound of randInt( is 0, you can replace it with int(#rand to save space. For example:

:randInt(0,12
can be
:int(13rand

Similarly, if you don't want to include zero in the range, you can use a variant of 1-#int(#rand:

:1-2int(2rand

In this particular example, the only values that you will ever get are -1 or 1.

Formulas

The value of randInt( for a given seed can be expressed in terms of rand:

randInt(A,B)=

  • when A<B, A+int((B-A+1)rand
  • otherwise, B+int((A-B+1)rand

This is identical to the output of randInt( in the sense that for the same seed, both expressions will generate the same random numbers.

Error Conditions

  • ERR:DOMAIN is thrown if any of the arguments is a decimal.
  • ERR: DATA TYPE is given if you use imaginary numbers like 6i or something like Matrices or Lists. This error is used instead of ERR:DOMAIN for "i".

Source: parts of this page were written by the following TI|BD contributors: burr, DarkerLine, GoVegan, nap386, Xeda Elnara.

History

Calculator OS Version Description
TI-83 0.01013 Added

Last update: September 30, 2023 15:38:51
Created: February 23, 2023 23:15:01
Authors: Adrien Bertrand