By running 10,000 permutations (shuffles) of A and B, generate a null distribution of differences between A and B.

computer science

Description

Q2 By running 10,000 permutations (shuffles) of A and B, generate a null distribution of differences between A and B.

If you find that this takes some time, you might want to have your for loop print out its current iteration so you can monitor its progress

 

Q3 Calculate the p-value of your observed difference. To do this, simply count the number of dfference values in the null distribution that are more extreme than the observed difference (in EITHER direction, positive or negative), and express this as a proportion of 10,000!

 

Q4 Plot this null distribution along with a vertical line where the observed difference was.

Include plot labels and a legend

 

Q5 Define a function to carry out this whole process

Your function should take as its input arguments:

  • The number of permutations to do
  • The population mean of A and B
  • The population standard deviation of A and B
  • The sample size of A and B

It should produce both plots generated above, with all input parameters described in the title

Furthermore, it should output:

  • The observed difference of your samples
  • The null distribution of differences from your permutations

Set the above values as the default values for your input parameters (values the input variables take if you do not specify them in the input argument list) by using this function definition:
def run_permtest(nperm=10000 , u=[100,102] , s=[4,4] , n=[60,60]):

 

Q6 Using your function above, see what happens when you eliminate the effect (i.e. population means of A and B are equal), but using the default values for the other parameters

Assign your outputs to unique variables so that you can use them again later.


Related Questions in computer science category