1. Learn
  2. /
  3. Courses
  4. /
  5. Practicing Statistics Interview Questions in Python

Connected

Exercise

Bernoulli distribution

Let's start simple with the Bernoulli distribution. In this exercise, you'll generate sample data for a Bernoulli event and then examine the visualization produced. Before we start, make yourself familiar with the rvs() function within scipy.stats that we'll use for sampling over the next few exercises.

Let's stick to the prior example of flipping a fair coin and checking the outcome: heads or tails. Remember that matplotlib is already imported as plt for you.

Instructions 1/3

undefined XP
  • 1

    Generate a sample using the rvs() function with size set to 100; assign it to the data variable.

  • 2

    Create and display a histogram using the hist() function; examine the shape of the distribution.

  • 3

    Adapt the code to take a sample of 1000 observations this time.