How to generate random normal distribution without numpy? (Google interview)
According to the Central Limit Theorem a normalised summation of independent random variables will approach a normal distribution. The simplest demonstration of this is adding two dice together.
So maybe something like:
import random
import matplotlib.pyplot as plt
def pseudo_norm():
"""Generate a value between 1-100 in a normal distribution"""
count = 10
values = sum([random.randint(1, 100) for x in range(count)])
return round(values/count)
dist = [pseudo_norm() for x in range(10_000)]
n_bins = 100
fig, ax = plt.subplots()
ax.set_title('Pseudo-normal')
hist = ax.hist(dist, bins=n_bins)
plt.show()
Which generates something like: