Chapter 9:

Exercise :14: A restaurant feeds 400 customers per day. On the average 20 percent of the customers order apple pie.

  1. Give a range (called a 95 percent confidence interval) for the number of pieces of apple pie ordered on a given day such that you can be 95 percent sure that the actual number will fall in this range.
#number of customers
n=400
p = 0.2 
q = 0.8
#mean
mu = n*p
mu
## [1] 80
#standard deviation
SD = sqrt((p*q)/n)
SD
## [1] 0.02
#95% confidence interval
#p-E, p+E
#E=Z*SD
E = 1.96 * SD
E
## [1] 0.0392
#p1=p-E Lower Limit
p1=p -E
p1
## [1] 0.1608
#p2=p+E Upper Limit
p2=p + E
p2
## [1] 0.2392
# Let X be number of apple pie ordered
#E(X) = np
#Lower limit =np1
ll = n * p1
ll
## [1] 64.32
#Upper limit =np2
ul = n * p2
ul
## [1] 95.68

95% confidence interval estimate for number of pieces of apple pie is (64.32 , 95.68 )

  1. How many customers must the restaurant have, on the average, to be at least 95 percent sure that the number of customers ordering pie on that day falls in the 19 to 21 percent range?

solving for SD in the equation for lower bound for 95% confidence interval

#p1= p - E
#E=2SD
p1=.19 #lower limit
p = 0.2
q = 0.8
# .19 = .2 - 2SD
SD = (0.2 -0.19)/2
SD
## [1] 0.005
#SD = sqrt((p*q)/n)
n = (p*q)/ SD^2
n
## [1] 6400

The restaurant must have 6400 customers.