1. Learn
  2. /
  3. Courses
  4. /
  5. Statistical Simulation in Python

Exercise

Generating a single permutation

In the next few exercises, we will run a significance test using permutation testing. As discussed in the video, we want to see if there's any difference in the donations generated by the two designs - A and B. Suppose that you have been running both the versions for a few days and have generated 500 donations on A and 700 donations on B, stored in the variables donations_A and donations_B.

We first need to generate a null distribution for the difference in means. We will achieve this by generating multiple permutations of the dataset and calculating the difference in means for each case.

First, let's generate one permutation and calculate the difference in means for the permuted dataset.

Instructions

100 XP
  • Concatenate the two arrays donations_A and donations_B using np.concatenate() and assign to data.
  • Get a single permutation using np.random.permutation() and assign it to perm.
  • Calculate the difference in the mean values of permuted_A and permuted_B as diff_in_means.