Session Ready
Exercise

Measuring a sample

Let's work with a sample of coin flips to calculate some probabilities. You will calculate absolute and relative frequency and check the theoretical value from the distribution of the sample data.

The array sample_of_two_coin_flips has 1,000 experiments, each consisting of two fair coin flips. For each experiment, we record the number of heads out of the two coin flips: 0, 1, or 2.

We've preloaded the binom object and the find_repeats() and relfreq() methods from the scipy.stats library for you. You'll need these to calculate the probabilities in this exercise.

Instructions 1/3
undefined XP
  • 1

    From the provided samples in sample_of_two_coin_flips, get the probability of having 2 heads out of the 1,000 trials.

    • 2

      Calculate the relative frequency from sample_of_two_coin_flips, set numbins as 3, and extract frequency.

    • 3

      Calculate the probability of getting 0, 1, or 2 from a binomial distribution with n=2 and p=0.5.