stargen/rnd.py
cecilkorik 3066899c07 initial import
--HG--
branch : stargen
2010-04-27 03:43:05 +00:00

22 lines
No EOL
431 B
Python

import random as random_lib
import math
def random():
return random_lib.random()
def gaussian(mean=0.0, stddev=1.0):
while True:
x1 = (2.0 * random()) - 1.0
x2 = (2.0 * random()) - 1.0
w = (x1 * x1) + (x2 * x2)
if w < 1.0:
break
w = math.sqrt((-2.0 * math.log(w)) / w)
return mean + (x1 * w * stddev)
def randrange(min, max):
return min + (random() * (max - min))