LoslegenKostenlos loslegen

Adding dice rolls

To illustrate the central limit theorem, we are going to work with dice rolls. We'll generate the samples and then add them to plot the outcome.

You're provided with a function named roll_dice() that will generate the sample dice rolls. numpy is already imported as np for your convenience: you have to use np.add(sample1, sample2) to add samples. Also, matplotlib.pyplot is imported as plt so you can plot the histograms.

Diese Übung ist Teil des Kurses

Foundations of Probability in Python

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Configure random generator
np.random.seed(42)

# Generate the sample
sample1 = ____(____)

# Plot the sample
plt.____(____, bins=range(1, 8), width=0.9)
plt.____()  
Code bearbeiten und ausführen