def Muller mev dis x2 while random uniform -1 random uniform -1 if and

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
def Muller(mev, dis):
x2 = []
while 1:
x = random.uniform(-1, 1)
y = random.uniform(-1, 1)
s = x**2 + y**2
if 0 < s and s <= 1:
z0 = x * math.sqrt(-2 * math.log(s) / s)
z1 = y * math.sqrt(-2 * math.log(s) / s)
x2.append(mev + dis * z0)
x2.append(mev + dis * z1)
if len(x2) == 20:
return x2
print Muller(mev, dis)