text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import random

import seaborn as sns

import random
import matplotlib
import matplotlib.pyplot as plt
def throw():
    global x
    x += random.randint(1, 6)
def multi_throw(dice_amount, list_name):
    global x
    x = 0
    for i in range(dice_amount):
        throw()
    list_name.append(x)
def multi_times(time_amount, dice_amount, list_name):
    for i in range(time_amount):
        multi_throw(dice_amount, list_name)

x = 0
th_amount = 1000000
my_list1 = []
my_list2 = []
my_list3 = []
my_list4 = []
multi_times(th_amount, 3, my_list1)
multi_times(th_amount, 4, my_list2)
multi_times(th_amount, 5, my_list3)
multi_times(th_amount, 6, my_list4)

fig, ax = plt.subplots()
plt.xlabel('score')
plt.ylabel('occurences')
plt.title('Histogram of '+str(th_amount)+' dice throws')

histy='step'

ax.hist(my_list3,
        bins=range(0,36),
        color="blue",
        alpha=0.8,
        )

plt.show()

fig, ax = plt.subplots()
plt.xlabel('score')
plt.ylabel('occurences')
plt.title('Histogram of '+str(th_amount)+' dice throws')

histy='step'

ax.hist(my_list4,
        bins=range(0,36),
        color="red",
        alpha=0.8,
        )

plt.show()

list_100 = []
multi_times(th_amount, 100, list_100)

fig, ax = plt.subplots()
plt.xlabel('score')
plt.ylabel('occurences')
plt.title('Histogram of '+str(th_amount)+' dice throws')

histy='step'

ax.hist(list_100,
        color="green",
        bins=range(275,425),
        alpha=0.8,
        )

plt.show()

fig, ax = plt.subplots()
plt.xlabel('score')
plt.ylabel('occurences')
plt.title('Histogram of '+str(th_amount)+' dice throws')

histy='step'

ax.hist(my_list4,
        bins=range(2,36),
        color="red",
        alpha=1.0,
        )

ax.hist(my_list3,
        bins=range(2,36),
        color="blue",
        alpha=0.8,
        )

ax.hist(my_list2, 
        bins=range(2,36),
        color="green",
        alpha=0.7,
        )

ax.hist(my_list1, 
        bins=range(2,36),
        color="yellow",
        alpha=0.5,
        )

ax.legend(["6 dices", "5 dices", "4 dices", "3 dices"])

plt.show()

import seaborn as sns

sns.distplot(my_list1, label='3 dices', kde=False)
sns.distplot(my_list2, label='4 dices', kde=False)
sns.distplot(my_list3, label='5 dices', kde=False)
sns.distplot(my_list4, label='6 dices', kde=False)
plt.legend()