Get startedGet started for free

Generating an approximate sampling distribution

Calculating the exact sampling distribution is only possible in very simple situations. With just five eight-sided dice, the number of possible rolls is 8**5, which is over thirty thousand. When the dataset is more complicated, for example, where a variable has hundreds or thousands of categories, the number of possible outcomes becomes too difficult to compute exactly.

In this situation, you can calculate an approximate sampling distribution by simulating the exact sampling distribution. That is, you can repeat a procedure over and over again to simulate both the sampling process and the sample statistic calculation process.

pandas, numpy, and matplotlib.pyplot are loaded with their usual aliases.

This exercise is part of the course

Sampling in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Sample one to eight, five times, with replacement
five_rolls = ____

# Print the mean of five_rolls
print(____)
Edit and Run Code