Is beak depth heritable at all in G. scandens?
The heritability of beak depth in G. scandens seems low. It could be that this observed heritability was just achieved by chance and beak depth is actually not really heritable in the species. You will test that hypothesis here. To do this, you will do a pairs permutation test.
This exercise is part of the course
Statistical Thinking in Python (Part 2)
Exercise instructions
- Initialize your array of replicates of heritability. We will take 10,000 pairs permutation replicates.
- Write a
forloop to generate your replicates.- Permute the
bd_parent_scandensarray usingnp.random.permutation(). - Compute the heritability between the permuted array and the
bd_offspring_scandensarray using theheritability()function you wrote in the last exercise. Store the result in the replicates array.
- Permute the
- Compute the p-value as the number of replicates that are greater than the observed
heritability_scandensyou computed in the last exercise.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Initialize array of replicates: perm_replicates
perm_replicates = ____
# Draw replicates
for i in range(10000):
# Permute parent beak depths
bd_parent_permuted = ____
perm_replicates[i] = ____
# Compute p-value: p
p = np.sum(____ >= ____) / len(____)
# Print the p-value
print('p-val =', p)