Defective Nails A manufacturer of nails claims that only 3% of its nails are defective. A random sample of 24 nails is selected and it is found that two of them are defective. Is it fair to reject the manufacturer's claim based on the observation?
I know that the number of defective nails is a binomial random variable with n=24 and p=0.03. I don't know how to show whether the claim is true or false.
 A: Answer:
$$H_0 : P_0 = 0.03$$
$$H_1 : P_0 > 0.03$$
$$ p = 0.0833$$
z statistic = $$\frac{(0.08333-.03)}{\sqrt{(0.03*.97)/24}} =1.53$$
At a confidence level $\alpha = 0.05$,
$Z_{\alpha} = -1.65$
Reject $H_0$ if Z-statistic < - 1.65 or Z-Statistic 
Reject the Claim and conclude that more than 3% of them are defective.
It is a one tailed test with $\alpha$ = .05 and hence you will find the critical value of $Z_{\alpha}$
A: Binomial (20, 0.03)
Therefore, the probability of find 2 defective nails 
1 - The probability that 2 or more nails are defective.
P(X>=2) = 1- P(X=0) - P(X=1) = 1 - (24C0)(1-0.03)^24 - (24) .03*(1-0.03)^23 = 0.161
This is still quite high probability of 16% of finding 2 defective nails; therefore it is not fair to reject the claim.
But if we found 3 defective parts, then P(X>=3) would be 0.03 and suspicious.
Here is Python program to compute the probability

#=============
N=24
k=2

p=0.03
q=1-p

s=0
for i in range(3):
    ncr = scipy.misc.comb(N, i)
    pp = p**(i)
    qq = q**(N-i)
    s += ncr * pp * qq

s, 1-s

# output (0.96585321479727937, 0.034146785202720631)

