For full credit, you must have the following items for each problem:
[1 point] Describe what and why the method you're using is applicable. For example, 'I chose the signed rank test because these are two matched datasets describing one measurement'
[1 point] Write out the null hypothesis. For example, 'The null hypothesis is that the two measurements sets came from the same population (synonymous with probability distribution)'
[1 point] Report the p-value and your alpha value (significance level)
[1 point] if you reject or not reject the null hypothesis and answer the question
Put your work into the python cell and your answer to the questions into the markdown cell
In [19]:
import scipy.stats as ss
import numpy as np
Z = (1070 - 1064) / 7
p = 1 - (ss.norm.cdf(Z - ss.norm.cdf(-Z)))
print(p)
In [17]:
Z = (3542 - 2341) / 120
p = 1 - (ss.norm.cdf(Z - ss.norm.cdf(-Z)))
print(p)
In [20]:
d = [7.5, 10 + 20/60, 8 + 25 / 60, 7 + 45/60, 9 + 20/60]
T = (np.mean(d) - 8) / (np.std(d, ddof=1) / np.sqrt(len(d)))
p = 1 - (ss.t.cdf(T, df=len(d)) - ss.t.cdf(-T, df=len(d)))
print(p)
Your manufacturing plant has made significant investment in improving quality control to improve yields. Your job is to determine if these investment have improved yields. Results on yield for the last 10 batches and from 5 batches from prior to the changes are available. Did these quality control improvements significantly change yields?
In [21]:
prior = [0.96, 0.97, 0.92, 0.88, 0.99]
post = [0.97, 0.96, 0.95, 0.97, 0.95, 0.85, 0.98, 0.77, 0.99, 0.97]
### BEGIN SOLUTION
ss.ranksums(prior, post)
### END SOLUTION
Out[21]:
In [7]:
control = [2, 0, 3, 4, 0, 2, 6, 3, 11, 4, 0, 4]
drug = [1, 0, 3, 2, 1, 0, 1, 2, 4, 2, 1, 2]
### BEGIN SOLUTION
import scipy.stats as ss
ss.wilcoxon(control, drug)
### END SOLUTION
Out[7]:
In [23]:
#11 is put into the interval of "extreme" values
#Or think about 11 is being in the interval that makes our
#estiamte more conservative
p = 1 - ss.poisson.cdf(11, 0.1 * 52)
print(p)
Sum of ranks test - they are from the same distribution
zM test - The dog is a labrador retriever
Poisson test - The rate of accidents follows the population Poisson distribution
Spearman correlation test - There is no correlation