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].

Examples

montecarlo 10000 with
  x = random.integer(6)
  sample avgDice = avg(x)

show scalar "Average of d6" with avgDice

This outputs the following scalar:

Average of d6
3.4899
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

Remarks

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.

User Contributed Notes
0 notes + add a note