def gauss(mu, sigma): while True: x1 = 2.0 * unif() - 1.0 x2 = 2.0 * unif() - 1.0 w = x1 * x1 + x2 * x2 if w < 1.0: w = math.sqrt((-2.0 * math.log(w)) / w) return x1 * w
def gauss2(mu, sigma): x1 = unif() x2 = unif() return math.sqrt(-2.0 * math.log(x1)) * math.cos(2 * math.pi * x2)