The Random Generator type and seed are set in the General section of the Analysis Environment. All subsequent tools that use random values (ArcGIS.Rand() [in Calculate Value and Calculate Field], Create Random Raster, and Create Random Points) will pull values from the stream. As each tool needs a random number, it will pull the next value from the global random stream.
You may want unique streams for each process to make sure the process is independently random, to not bias your results or to reproduce the output. You can create a stream locally by setting the random number generator and seed locally (for example, through the Environments... button on a tool or by right-clicking a tool in ModelBuilder and clicking the Properties... button). A new random stream is created, and when that tool needs a random value, it will pull only from this newly created stream. If the model iterates, the tool with the assigned random stream will continue to pull values from the local stream with each iteration. No other tools will pull values from the stream.
You can start as many local streams within a model as you want. You can also have a mixture of some tools pulling random values from the global stream while others pull values from their own local stream.
You can start as many local streams within a model as you want. You can also have a mixture of some tools pulling random values from the global stream while others pull values from their own local stream.
Adding randomness to a parameter in a ModelBuilder model is a five-step process. In the following ModelBuilder example, the z-factor to the Spatial Analyst slope function will be randomly changed.
- The Slope tool from the Spatial Analyst Tools toolbox in the Surface toolset is added.
- The Calculate Value tool from the Data Management Tools toolbox in the General toolset is added.
- An expression is input into the Calculate Value tool, and if randomness is to be added to the expression, the ArcGIS.Rand() function will be input into the expression with some arithmetic operation (or any expression). The expression to be processed in this example is, arcgis.rand("Normal 2 2") * 2.
- The relationship is made between the output of Calculate Value and the parameter to which randomness is being added (the Z factor in the Slope tool). To do so, open the Slope tool and in the Z factor field select the output variable name from the drop down list (output_value).
- Right-click the slope tool, click Properties... then make the output from Calculate Value tool a precondition to the Slope tool. This last step will ensure that the expression in the Calculate Value tool, the Z factor, will always be calcuated prior to running the Slope tool.
- Run the model.
Assigning random values to randomly placed points is a three-step process. First, a specified number of points are placed with the Create Random Points tool. Second, the Add Field tool is used to create a new field in the output feature layer from the Create Random Points tool. Third, the Calculate Field tool is used to assign the random values to the newly created field by directly using the ArcGIS.Rand() function with a distribution as a simple expression or by using the ArcGIS.Rand() function in a complex expression.