randsleep#
- randsleep(delay=1.0, var=1.0, low=None, high=None, seed=None)[source]#
Sleep for a nondeterminate period of time (useful for desynchronizing tasks)
- Parameters:
delay (float/list) – average duration in seconds to sleep for; if a pair of values, treat as low and high
var (float) – how much variability to have (default, 1.0, i.e. from 0 to 2*interval)
low (float) – optionally define lower bound of sleep
high (float) – optionally define upper bound of sleep
seed (int) – if provided, reset the random seed
- Examples::
sc.randsleep(1) # Sleep for 0-2 s (average 1.0) sc.randsleep(2, 0.1) # Sleep for 1.8-2.2 s (average 2.0) sc.randsleep([0.5, 1.5]) # Sleep for 0.5-1.5 s sc.randsleeep(low=0.5, high=1.5) # Ditto
New in version 2.0.0. New in version 3.0.0: “seed” argument