# Aside: Fast Permutation Tests¶

## Speeding things up 🏃¶

### Speeding up permutation tests¶

• A permutation test, like all simulation-based hypothesis tests, generates an approximation of the distribution of the test statistic.
• If we found all permutations, the distribution would be exact!
• If there are $a$ elements in one group and $b$ in the other, the total number of permutations is ${a + b \choose a}$.
• If $a = 100$ and $b = 150$, there are more than ${250 \choose 100} \approx 6 \cdot 10^{71}$ permutations!
• The more repetitions we use, the better our approximation will be.
• Unfortunately, our code is pretty slow, so we can't use many repetitions.

### Example: Birth weight and smoking 🚬¶

Recall our permutation test from last class:

• Null Hypothesis: In the population, birth weights of smokers' babies and non-smokers' babies have the same distribution, and the observed differences in our samples are due to random chance.
• Alternative Hypothesis: In the population, smokers' babies have lower birth weights than non-smokers' babies, on average. The observed difference in our samples cannot be explained by random chance alone.

### Timing the birth weights example ⏰¶

We'll use 3000 repetitions instead of 500.