CreateRandomValueGenerator

摘要

Creates a new random number generator.

语法

CreateRandomValueGenerator (seed, distribution)
参数说明数据类型
seed

Initializes the random number generator.

Integer
distribution

The random generation algorithm.

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

(默认值为 ACM599)

String
返回值
数据类型说明
Object

The RandomNumberGenerator object.

代码示例

CreateRandomValueGenerator example

Create and initialize random number generator object.

import arcpy
from arcpy import env

#   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.
#
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
#
val = float(result.getOutput(0))
print val

相关主题


7/10/2012