import random as random_lib
import math

def random():
	return random_lib.random()

def gaussian(mean=0.0, stddev=1.0, skew=0.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)

	if skew == 0.0:
		return mean + (x1 * w * stddev)
	else:
		sigma = skew / math.sqrt(1 + skew**2)
		v1 = x1 * w
		v2 = x2 * w
		m = 1.0
		if v1 < 0.0:
			m = -1.0
		
		vr = sigma * v1 + math.sqrt(1.0 - sigma**2) * v2
		return (vr * m * stddev) + mean
		
		
def randsign():
	if random() >= 0.5:
		return 1.0
	else:
		return -1.0


def randrange(min, max):
	return min + (random() * (max - min))