Current state - before further changes

This commit is contained in:
Danny Staple
2022-12-04 19:03:49 +00:00
parent 38e26f9bb9
commit bac9e4b69c
16 changed files with 1581 additions and 11 deletions
+15
View File
@@ -0,0 +1,15 @@
import random
import math
def get_standard_normal_sample():
"""Using the Marasaglia Polar method"""
while True:
u = random.uniform(-1, 1)
v = random.uniform(-1, 1)
s = u * u + v * v
if s >= 1:
continue
return u * math.sqrt(-2 * math.log(s) / s)
def get_gaussian_sample(mean, standard_deviation):
return get_standard_normal_sample() * standard_deviation + mean