Random Number Generator (Environment setting)

Tools that use the Random Number Generator environment use algorithms that use the seed and distribution to produce a sequence of random numbers.

Usage notes

Dialog syntax

Scripting syntax

arcpy.env.randomGenerator = random_generator_option



seed {distribution}

  • The seed is an integer value and is used to initiate the random number generator. The default value is 0.
  • The distribution is the random generation algorithm.
    • ACM599—ACM collected algorithm 599. This is the default.
    • MERSENNE_TWISTER—Mersenne Twister mt19937.
    • STANDARD_C—Standard C Rand.

RandomNumberGenerator class

A RandomNumberGenerator can be created using the CreateRandomValueGenerator function or returned from randomGenerator environment.

randomGenerator syntax

Create a random value using the Calculate Value tool.

import arcpy

# Set the randomGenerator environment to 4 MERSENNE_TWISTER
arcpy.env.randomGenerator = "4 MERSENNE_TWISTER"

# Calculate a random number using the arcgis.rand() function 
result = arcpy.CalculateValue_management("arcgis.rand('normal 0.0 10.0')") 

# Get the value from the result object from CalculateValue and print 
randomValue = float(result.getOutput(0)) 
print randomValue

Related Topics