Python program demonstrating Gaussian Distribution of k sums of n dice rolls.

# © 2019 TheFlyingKeyboard and released under MIT License # theflyingkeyboard.net from matplotlib import pyplot as plt from pylab import rcParams import random def get_sum_of_n_rolls(n): sum = 0 for i in range(n): sum += random.randrange(1, 7, 1) return sum n = 5 rolls = [get_sum_of_n_rolls(n) for _ in range(1000000)] data = [] for i in range(n, n * 6 + 1): data.append(rolls.count(i)) rcParams['figure.figsize'] = 16, 9 plt.gca().yaxis.grid(True) plt.xlabel("Sum of " + str(n) + " rolls") plt.ylabel("Count") plt.bar([i for i in range(n, n * 6 + 1)], data) plt.show()

Python Gaussian Distribution – Dice Rolls