Learn

The first step in running a hypothesis test is to form a null hypothesis. For the question of whether the purchase rate at Live-it-LIVE.com was different from 10% this month, the null hypothesis describes a world in which the true probability of a visitor making a purchase was exactly 10%, but by random chance, we observed that only 41 visitors (8.2%) made a purchase.

Let’s return to the coin flip example from the previous exercise. We can simulate 10 coin flips and print out the number of those flips that came up heads using the following code:

``````flips = np.random.choice(['heads', 'tails'], size=10, p=[0.5, 0.5])
## output: 4``````

If we run this code a few times, we’ll likely see different results each time. This will give us get a sense for the range in the number of heads that could occur by random chance, even if the coin is fair. We’re more likely to see numbers like four, five, or six, but maybe we’ll see something more extreme every once in a while — ten heads in a row, or even zero!

### Instructions

1.

In script.py, you’ll see the code we used in the previous exercise to generate `simulated_monthly_visitors`, a list of 500 simulated outcomes, `'y'` (with probability 0.1) or `'n'`, indicating whether each imaginary site visitor made a purchase.

Add a line of code to calculate the number of those simulated visitors who made a purchase. Save the result as `num_purchased` and print it out.

2.

Inspect the value of `num_purchased` from the previous instruction. Is it close to 50 (which is what we would expect for a purchase probability of 10%)? Less than? Greater than? Now try pressing “Run” a few more times and see what other values of `num_purchased` you observe. What’s the farthest number from 50 that you observe after pressing “Run” 5 times?