CreateRandomValueGenerator (arcpy)

Récapitulatif

Creates a new random number generator.

Syntaxe

CreateRandomValueGenerator (seed, distribution)
ParamètreExplicationType de données
seed

Initializes the random number generator.

Integer
distribution

The random generation algorithm.

  • ACM599ACM collected algorithm 599
  • MERSENNE_TWISTERMersenne Twister mt19937
  • STANDARD_CStandard C Rand

(La valeur par défaut est ACM599)

String
Valeur renvoyée
Type de donnéesExplication
Object

The RandomNumberGenerator object.

Exemple de code

CreateRandomValueGenerator example

Create and initialize random number generator object.

import arcpy

# CreateRandomValueGenerator takes 2 arguments, seed and distribution
# method. The distribution method options are ACM599,
# MERSENNE_TWISTER, and STANDARD_C.
#
# The gen variable is a randomNumberGenerator object that is assigned
# to the randomGenerator environments setting.
arcpy.env.randomGenerator = arcpy.CreateRandomValueGenerator(20, "STANDARD_C")

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

# Print the returned value from the Result object
print(float(result.getOutput(0)))

Thèmes connexes

4/26/2014