Get startedGet started for free

A time-on-website analog

It turns out that you already did a hypothesis test analogous to an A/B test where you are interested in how much time is spent on the website before and after an ad campaign. The frog tongue force (a continuous quantity like time on the website) is an analog. "Before" = Frog A and "after" = Frog B. Let's practice this again with something that actually is a before/after scenario.

We return to the no-hitter data set. In 1920, Major League Baseball implemented important rule changes that ended the so-called dead ball era. Importantly, the pitcher was no longer allowed to spit on or scuff the ball, an activity that greatly favors pitchers. In this problem you will perform an A/B test to determine if these rule changes resulted in a slower rate of no-hitters (i.e., longer average time between no-hitters) using the difference in mean inter-no-hitter time as your test statistic. The inter-no-hitter times for the respective eras are stored in the arrays nht_dead and nht_live, where "nht" is meant to stand for "no-hitter time."

Since you will be using your draw_perm_reps() function in this exercise, it may be useful to remind yourself of its call signature: draw_perm_reps(d1, d2, func, size=1) or even referring back to the chapter 3 exercise in which you defined it.

This exercise is part of the course

Statistical Thinking in Python (Part 2)

View Course

Exercise instructions

  • Compute the observed difference in mean inter-nohitter time using diff_of_means().
  • Generate 10,000 permutation replicates of the difference of means using draw_perm_reps().
  • Compute and print the p-value.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Compute the observed difference in mean inter-no-hitter times: nht_diff_obs
nht_diff_obs = ____

# Acquire 10,000 permutation replicates of difference in mean no-hitter time: perm_replicates
perm_replicates = ____


# Compute and print the p-value: p
p = ____
print('p-val =', p)
Edit and Run Code