Exercise

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.

Instructions 1/3

undefined XP
  • 1

    Generate a sample of 2000 dice rolls using roll_dice() and plot a histogram of the sample.

  • 2

    Add sample1 and sample2 using np.add(), store the result in the variable sum_of_1_and_2, then plot sum_of_1_and_2.

  • 3

    Add sum_of_1_and_2 and sample3 using np.add() and store the result in sum_of_3_samples. Then plot sum_of_3_samples.