摘要
创建新的随机数生成器。
语法
CreateRandomValueGenerator (seed, distribution)
参数 | 说明 | 数据类型 |
seed | 初始化随机数生成器。 | Integer |
distribution | 随机生成算法。
(默认值为 ACM599) | String |
返回值
数据类型 | 说明 |
Object | RandomNumberGenerator 对象。 |
代码示例
CreateRandomValueGenerator 示例
创建并初始化随机数生成器对象。
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)))