Skip to content

Instantly share code, notes, and snippets.

@bertptrs
Last active April 10, 2019 15:32
Show Gist options
  • Save bertptrs/61320fecc538f9e44d358c19b00d2449 to your computer and use it in GitHub Desktop.
Save bertptrs/61320fecc538f9e44d358c19b00d2449 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import itertools
import matplotlib.pyplot as plt
import numpy as np
D6 = np.arange(0, 6) + 1
two_dice = np.array([a + b for a, b in itertools.product(D6, D6)])
no_fives = np.array([x for x in two_dice if x != 5])
WINNINGS = np.array([-5, 0, 1.5, 0, -1, 1, 0, 1, 0, -1.5, 5])
N = 300 # Er zijn 300 tickets in de Dies
M = 10000 # We gaan 10000 keer de Dies vieren
worpen = np.random.choice(no_fives, N * M)
winsten = WINNINGS[worpen - 2].reshape((M, N))
gem = np.sum(winsten, 1) / N
plt.xlabel("Winst")
plt.ylabel("Frequentie")
plt.hist(gem)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment