Session Ready
Exercise

Calculating the mean and variance of a sample

Now that you're familiar with working with coin flips using the binom object and calculating the mean and variance, let's try simulating a larger number of coin flips and calculating the sample mean and variance. Comparing this with the theoretical mean and variance will allow you to check if your simulated data follows the distribution you want.

We've preloaded the binom object and the describe() method from scipy.stats for you, as well as creating an empty list called averages to store the mean of the sample variable and a variable called variances to store the variance of the sample variable.

Instructions 1/3
undefined XP
  • 1
  • 2
  • 3
  • Inside a loop, create a sample variable with 10 trials of 10 coin flips with 25% probability of getting heads.