-
Notifications
You must be signed in to change notification settings - Fork 5
Random Number Generators
Random Number Generators (RNGs) are used throughout STEPWAT2 to simulate stochastic processes like establishment and wildfire. Each module in STEPWAT2 has its own random number generator.
An RNG, in computing terms, is a function that returns a different random number every time it is called. For example, if I am using a RNG called f
,
f()
f()
f()
might return
28
3
67
In an ideal world there would be no way to guess what value a random number generator would return next. Unfortunately, computers are not capable of generating truly random numbers. Computers are deterministic, meaning that if we run a random number generator on a computer, write down the numbers, restart the computer, then run it again, we will get the same sequence of random numbers:
First run | Second run |
---|---|
86 | 86 |
15 | 15 |
4 | 4 |
55 | 55 |
To combat this problem random number generators are initialized with a seed. For every seed you can think of there is a entirely different sequence of random numbers generated by a single RNG. In the example above we can solve our problem by using a different seed each time:
First run with seed = 8 | Second run with seed = 7 |
---|---|
33 | 1 |
88 | 60 |
24 | 65 |
27 | 3 |
Therefore, when we talk about a random number generator in STEPWAT2 we really mean two things:
- A function that returns random values.
- A seed to ensure different results every time.
The seed is set in the model.in file.
Most of the time we will want a random number sequence that we have never seen before. The most common solution in computer science is to use the current time to seed the random number generator. Time never repeats itself so we are guaranteed that each run our RNG will produce different random results.
However, there are some instances where we want to use the same seed. For example, if we want to prove that changing a specific input parameter has no impact on the program we could try setting the seed to the same number for two simulations and see if the results are identical. For developers using the same seed is a good way to make sure that a feature we added to the code does not contain a bug.
Input Parameters
- rgroup.in
- species.in
- bmassflags.in
- env.in
- maxrgroupspecies.in
- model.in
- mortflags.in
- plot.in
- sxw.in
- sxwdebug.in