# A company has known that their screws is defective with probability 0.1.
# They sell the screws in packages of 10, and are planning a
# money-back guarantee: They replace it
# (a) if a customer find more than two defective screws;
# (b) if one defective is found.
# For each of the money-back guarantee plans (a) and (b),
# what proportion of packages sold must be replaced?
n = 10
p = 0.01
x = -1:(n+1)
cdf = pbinom(x,n,p)
plot(x,cdf,type='s',col='blue')
lines(c(-1,n+1),c(1,1),lty=2,col='red')
# Answers are calculated as follows.
print(1 - pbinom(1,n,p))
print(1 - pbinom(0,n,p))
