1. Learn
  2. /
  3. Courses
  4. /
  5. Sampling in Python

Connected

Exercise

Sampling distribution vs. bootstrap distribution

The sampling distribution and bootstrap distribution are closely linked. In situations where you can repeatedly sample from a population (these occasions are rare), it's helpful to generate both the sampling distribution and the bootstrap distribution, one after the other, to see how they are related.

Here, the statistic you are interested in is the mean popularity score of the songs.

spotify_population (the whole dataset) and spotify_sample (500 randomly sampled rows from spotify_population) are available; pandas and numpy are loaded with their usual aliases.

Instructions 1/2

undefined XP
  • 1
    • Generate a sampling distribution of 2000 replicates using a for loop.
    • Sample 500 rows of the population without replacement and calculate the mean popularity.
  • 2
    • Sample 500 rows of the sample with replacement and calculate the mean popularity to generate a bootstrap distribution of 2000 replicates.