ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Random Number Generator (Environment setting)

  • Usage notes
  • Dialog syntax
  • Scripting syntax

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

  • If a tool using the random values (for example, Create Random Raster, Create Random Points, or Calculate Value) runs twice with the same seed, the output is identical. Control over the seed allows you to reproduce your results.
  • If a random number generator is defined globally, one stream of random values are created. Each subsequent tool or tools within a ModelBuilder model pulls the next available value from the stream as needed.
  • Multiple random number generator streams can be used in a ModelBuilder model by creating them locally for the desired tools that use random numbers. Each tool can have its own stream from which to pull random values as needed. Only the tool with the local stream can pull values from that stream. There is no limit to the number of local streams.

Dialog syntax

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

Scripting syntax

arcpy.env.randomGenerator = random_generator_option

random_generator_optionExplanation

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 the 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[0])
print(randomValue)

Related Topics

  • Distributions for assigning random values
  • The distribution syntax for random values
  • Random number generators and streams
  • CreateRandomValueGenerator
  • An overview of geoprocessing environments
  • Environment levels and hierarchy
  • Setting geoprocessing environments
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal