Navigation :
random.integer
random.integer, function
def autodiff pure random.integer(max: number): number
def pure random.integer(min: number, max: number): number
Draws a random integer in the inclusive range [min, max]. The single-argument
overload uses [1, max].
min: the inclusive lower bound.
max: the inclusive upper bound.
Examples
montecarlo 10000 with
x = random.integer(6)
sample avgDice = avg(x)
show scalar "Average of d6" with avgDice
This outputs the following scalar:
montecarlo 10000 with
y = random.integer(-2, 2)
sample avgRange = avg(y)
show scalar "Average of [-2, 2]" with avgRange
This outputs the following scalar:
| Average of [-2, 2] |
| 0.0288 |
The max argument must be at least 1, and min must be less than or equal to
max. Only the single-argument overload is usable inside
autodiff blocks.