Question
A baker blends 600 raisins and 400 chocolate chips into a dough mix and, from this, makes 500 cookies.
a. Find the probability that a randomly picked cookie will have no raisins.
b. Find the probability that a randomly picked cookie will have exactly two chocolate chips.
c. Find the probability that a randomly chosen cookie will have at least two bits (raisins or chips) in it.
Solution
Let’s first create variables for our raisins, chips, and cookies:
numR <- 600
numCC <- 400
numC <- 500
avgRperC <- numR / numC
avgCCperC <- numCC / numC
avgBitsperC <- (numR + numCC) / numC
a. Find the probability that a randomly picked cookie will have no raisins.
We know that the average number of raisins per cookie is:
avgRperC
## [1] 1.2
As a gut check, we would expect the probability of no raisins per cookie to be low. We will model this using a Poission Distribution: \[P(X=x)=\frac{e^{-\lambda}\lambda^{x}}{x!}\]
where \(\lambda\) is the average number of raisins per cookie, and \(x\) is 0 raisins.
x <- 0
noRaisins <- (exp(-avgRperC)* avgRperC^x)/factorial(x)
noRaisins
## [1] 0.3011942
b. Find the probability that a randomly picked cookie will have exactly two chocolate chips.
We know that the average number of chocolate chips per cookie is:
avgCCperC
## [1] 0.8
As a gut check, we know that the probability of exactly 2 chocolate chips should be low. Once again, we will model this using a poisson distribution, this time with \(\lambda\) as the average number of chocolate chips per cookie, and \(x\) as 2 chips.
x2 <- 2
twoChips <- (exp(-avgCCperC)* avgCCperC^x2)/factorial(x2)
twoChips
## [1] 0.1437853
c. Find the probability that a randomly chosen cookie will have at least two bits (raisins or chips) in it.
We know that the average number of bits per cookie is:
avgBitsperC
## [1] 2
We will model this by calculating the complement of the probability of there being 0 or 1 bits in the cookie:
\[P(X>2)=1-[P(X=0)+P(X=1)]\]
x3 <- 0
x4 <- 1
prob0 <- (exp(-avgBitsperC)* avgBitsperC^x3)/factorial(x3)
prob1 <- (exp(-avgBitsperC)* avgBitsperC^x4)/factorial(x4)
prob2orMore <- 1 - (prob0+prob1)
prob2orMore
## [1] 0.5939942