X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/ae63d7db7c6cf2e015e0a59645031d7ddac817a6..0e82b3c21c1e2a5c18149bf5834b46eed877898e:/unitproc/python/sleepRand.py?ds=sidebyside diff --git a/unitproc/python/sleepRand.py b/unitproc/python/sleepRand.py index 76a32e1..3454d24 100755 --- a/unitproc/python/sleepRand.py +++ b/unitproc/python/sleepRand.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # Desc: Pauses a random amount of time. Random distribution is inverse gaussian. -# Version: 0.0.1 +# Version: 0.0.3 # Depends: python 3.7.3 # Usage: ./sleepRand.py arg1 # Input: arg1: float seconds (mean of inverse gaussian distribution) @@ -8,9 +8,16 @@ import math, time, random, sys +# Adjustments +lambdaFactor = 4; # spread factor; inversely proportional to variance + # Define functions def randInvGau(mu, lam): """Returns random variate of inverse gaussian distribution""" + # input: mu: mean of inverse gaussian distribution + # lam: shape parameter + # output: float sampled from inv. gaus. with range 0 to infinity, mean mu + # example: sample = float(randInvGau(1.0,4.0)); # Ref/Attrib: doi:10.1080/00031305.1976.10479147 nu = random.gauss(0,1); y = nu ** 2; @@ -28,9 +35,6 @@ def randInvGau(mu, lam): arg1 = float(sys.argv[1]); # first argument desMean = arg1; -# Configure -lambdaFactor = 4; # spread factor; inversely proportional to variance - # Calculate delay delay = randInvGau(desMean, desMean * lambdaFactor); #print('DEBUG:delay:' + str(float(delay))); @@ -38,4 +42,5 @@ delay = randInvGau(desMean, desMean * lambdaFactor); # Sleep time.sleep(float(delay)); - +# Author: Steven Baltakatei Sandoal +# License: GPLv3+