:py:mod:`gnome.utilities.rand` ============================== .. py:module:: gnome.utilities.rand .. autoapi-nested-parse:: rand.py Contains functions for adding randomness - not to confuse with standard python random functions Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: gnome.utilities.rand.random_with_persistance gnome.utilities.rand.seed .. py:function:: 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 :param low: lower bound for random number; should be an array, tuple, list :param high: upper bound for random number; should be an array, tuple, list :param 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 :param time_step: step size for the simulation in seconds. :param 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. .. py:function:: seed(seed=1) Set the C++, the python and the numpy random seed to desired value :param seed: Random number generator should be seeded by this value. Default is 1