A one-sample bootstrap hypothesis test
Another juvenile frog was studied, Frog C, and you want to see if Frog B and Frog C have similar impact forces. Unfortunately, you do not have Frog C's impact forces available, but you know they have a mean of 0.55 N. Because you don't have the original data, you cannot do a permutation test, and you cannot assess the hypothesis that the forces from Frog B and Frog C come from the same distribution. You will therefore test another, less restrictive hypothesis: The mean strike force of Frog B is equal to that of Frog C.
To set up the bootstrap hypothesis test, you will take the mean as our test statistic. Remember, your goal is to calculate the probability of getting a mean impact force less than or equal to what was observed for Frog B if the hypothesis that the true mean of Frog B's impact forces is equal to that of Frog C is true. You first translate all of the data of Frog B such that the mean is 0.55 N. This involves adding the mean force of Frog C and subtracting the mean force of Frog B from each measurement of Frog B. This leaves other properties of Frog B's distribution, such as the variance, unchanged.
Este ejercicio forma parte del curso
Statistical Thinking in Python (Part 2)
Instrucciones de ejercicio
- Translate the impact forces of Frog B such that its mean is 0.55 N.
- Use your
draw_bs_reps()
function to take 10,000 bootstrap replicates of the mean of your translated forces. - Compute the p-value by finding the fraction of your bootstrap replicates that are less than the observed mean impact force of Frog B. Note that the variable of interest here is
force_b
. - Print your p-value.
Ejercicio interactivo práctico
Pruebe este ejercicio completando este código de muestra.
# Make an array of translated impact forces: translated_force_b
translated_force_b = ____
# Take bootstrap replicates of Frog B's translated impact forces: bs_replicates
bs_replicates = draw_bs_reps(____, ____, 10000)
# Compute fraction of replicates that are less than the observed Frog B force: p
p = np.sum(____ <= np.mean(____)) / 10000
# Print the p-value
print('p = ', ____)