gnome.utilities.rand¶
rand.py
Contains functions for adding randomness - not to confuse with standard python random functions
Functions¶
|
Used by gnome to generate a randomness between low and high, which is |
|
Set the C++, the python and the numpy random seed to desired value |
Module Contents¶
- gnome.utilities.rand.random_with_persistance(low, high, array=None, persistence=None, time_step=1.0)¶
Used by gnome to generate a randomness between low and high, which is persistent for duration time_step
- Parameters:
low – lower bound for random number; should be an array, tuple, list
high – upper bound for random number; should be an array, tuple, list
array – array to be updated. Must be same length as ‘low’, ‘high’, ‘persistence’. Default is None in which case the computed array is simply returned
time_step – step size for the simulation in seconds.
persistence – in seconds. Since we add randomness for each timestep, the persistence parameter is used to make the randomness invariant to size of time_step. Default is None. If persistence is None, it gets set equal to ‘time_step’. If persistence < 0 for any elements, their values are not updated in the ‘array’
- Returns:
returns ‘array’ with newly computed values
- Note: persistence and time_step should be in the same time units
Assumes both low and high are int/float or arrays, lists, tuples. For lists, arrays, tuples - it converts input to numpy array with dtype=float
If ‘low’ is an array, list or tuple, then ‘high’ and ‘persistence’ should also be the same length array, list or tuple. Give all 3 parameters for each element of the array.
- gnome.utilities.rand.seed(seed=1)¶
Set the C++, the python and the numpy random seed to desired value
- Parameters:
seed – Random number generator should be seeded by this value. Default is 1