We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fd504eb commit 203ac27Copy full SHA for 203ac27
amdahl/amdahl.py
@@ -96,8 +96,15 @@ def random_jitter(x, sigma=0.2):
96
"""
97
Apply a random offset of ±20% to a value
98
99
- y_min = x - sigma
100
- return y_min + 2 * sigma * random.random()
+ # Make sure sigma is between 0 and 1
+ if sigma < 0 or sigma > 1 :
101
+ sys.stdout.write(
102
+ "Illegal value for sigma (%f), should be a float between 0 and 1!\n" % sigma
103
+ "Using 0.2 instead..."
104
+ sigma = 0.2
105
+ # random() returns a float between 0 and 1, map between -sigma and +sigma
106
+ jitter_percent = sigma * ((random.random() * 2) - 1)
107
+ return (1 + jitter_percent) * x
108
109
110
def parse_command_line():
0 commit comments