Homework 6, Combinatorics / Conditional Probability

Question 1. A bag contains 5 green and 7 red jellybeans. How many ways can 5 jellybeans be withdrawn from the bag so that the number of green ones withdrawn will be less than 2?

\[\begin{equation*} \binom{5}{1} =\frac{5!}{(5-1)!1!} =\frac{120}{24} \\ \binom{7}{4} =\frac{7!}{(7-4)!4!} =\frac{5,040}{144} \\ \binom{7}{5} =\frac{7!}{5!(7-5)!} =\frac{5,040}{240} \\ =\ \binom{5}{1} \times \binom{7}{4} +\binom{7}{5} \\= 175 + 21 = 196\ ways\ \end{equation*}\]

Q1 <- choose(5,1) * choose(7,4) + choose(7,5)
print(paste0("The total ways 5 jellybeans can be withdrawn from the bag so that the number of green ones withdrawn will be less than 2 is: ",Q1))
## [1] "The total ways 5 jellybeans can be withdrawn from the bag so that the number of green ones withdrawn will be less than 2 is: 196"

Question 2. A certain congressional committee consists of 14 senators and 13 representatives. How many ways can a subcommittee of 5 be formed if at least 4 of the members must be representatives?

\[\begin{equation*} \binom{13}{4}=\frac{13!}{4!(13-4)!} =\frac{6227020800}{8709120} \\ \binom{14}{1}=\frac{14!}{1!(14-1)!} =\frac{87178291200 }{6227020800} \\ \binom{13}{5} =\frac{13!}{5!(13-5)!} =\frac{6227020800}{4838400} \\ = \binom{13}{4} \times \binom{14}{1} +\binom{13}{5} \\= 10,010 + 1,287 \\Answer:\ =\ 11,297\ ways \end{equation*}\]

Q2 <- choose(13,4)*choose(14,1) + choose(13,5)
print(paste0("The total ways a subcommittee of 5 be formed if at least 4 of the members must be representatives is: ",Q2))
## [1] "The total ways a subcommittee of 5 be formed if at least 4 of the members must be representatives is: 11297"

Question 3. If a coin is tossed 5 times, and then a standard six-sided die is rolled 2 times, and finally a group of three cards are drawn from a standard deck of 52 cards without replacement, how many different outcomes are possible?

\[\begin{equation*} =2^{5} \times 6^{2} \times \frac{52!}{3!(52-3)!} \\ = 32 \times 36 \times 22100 \\ = 25,459,200 \ outcomes \end{equation*}\]

Q3 <- 2^5 * 6^2 * choose(52,3)
print(paste0("The total different outcomes are possible is: ",Q3))
## [1] "The total different outcomes are possible is: 25459200"

Question 4. 3 cards are drawn from a standard deck without replacement. What is the probability that at least one of the cards drawn is a 3? Express your answer as a fraction or a decimal number rounded to four decimal places.

\[\begin{equation*} P = 1 - \frac{48}{52} \times \frac{47}{51} \times \frac{46}{50} \\ P = 0.2173756 \end{equation*}\]

Q4 <- round(((choose(4,1) * choose(48,2)) + (choose(4,2) * choose(48,1)) + choose(4,3)) / choose(52,3),4)
print(paste0("The probability that at least one of the cards drawn is a 3 is: ",Q4))
## [1] "The probability that at least one of the cards drawn is a 3 is: 0.2174"

Question 5. Lorenzo is picking out some movies to rent, and he is primarily interested in documentaries and mysteries. He has narrowed down his selections to 17 documentaries and 14 mysteries.

Step 1. How many different combinations of 5 movies can he rent?

\[\begin{equation*} =\ \binom{31}{5} =\frac{31!}{(31-5)!5!} \\ =169,911 \end{equation*}\]

Q5_S1 <- choose(31,5)
print(paste0("The total different combinations of 5 movies can he rent is: ",Q5_S1))
## [1] "The total different combinations of 5 movies can he rent is: 169911"

Step 2. How many different combinations of 5 movies can he rent if he wants at least one mystery?

\[\begin{equation*} \binom{14}{1} \times \binom{17}{4} = \frac{14!}{1!(14-1)!} \times \frac{17!}{4!(17-4)!} \\ \binom{14}{2} \times \binom{17}{3} = \frac{14!}{2!(14-2)!} \times \frac{17!}{3!(17-3)!} \\ \binom{14}{3} \times \binom{17}{2} = \frac{14!}{3!(14-3)!} \times \frac{17!}{2!(17-2)!} \\ \binom{14}{4} \times \binom{17}{1} = \frac{14!}{4!(14-4)!} \times \frac{17!}{1!(17-1)!} \\ \binom{14}{5} = \frac{14!}{5!(14-5)!} \\ \\ That\ is\ =\ \binom{14}{1} \times \binom{17}{4} + \binom{14}{2} \times \binom{17}{3} + \binom{14}{3} \times \binom{17}{2} + \binom{14}{4} \times \binom{17}{1} + \binom{14}{5} \\ = 33,320 + 61,880 + 49,504 + 17,017 + 2,002 \\ = 163,723 \end{equation*}\]\end{equation*}

Q5_S2 <- (choose(14,1) * choose(17,4)
) + (choose(14,2) * choose(17,3)) + (choose(14,3) * choose(17,2)) + (choose(14,4) * choose(17,1)) + (choose(14,5))
print(paste0("The total different combinations of 5 movies can he rent if he wants at least one mystery is: ",Q5_S2))
## [1] "The total different combinations of 5 movies can he rent if he wants at least one mystery is: 163723"

Question 6. In choosing what music to play at a charity fund raising event, Cory needs to have an equal number of symphonies from Brahms, Haydn, and Mendelssohn. If he is setting up a schedule of the 9 symphonies to be played, and he has 4 Brahms, 104 Haydn, and 17 Mendelssohn symphonies from which to choose, how many different schedules are possible? Express your answer in scientific notation rounding to the hundredths place.

\[\begin{equation*} =\ \binom{4}{3} =\frac{4!}{(4-3)!3!} = 4\ ways\ for\ Brahms\ symphonies\ \\ \binom{104}{3} =\frac{104!}{(104-3)!3!} = 182,104\ ways\ for\ Haydn\ symphonies\ \\ \binom{17}{3} = \frac{17!}{(17-3)!3!} = 680\ ways\ for\ symphonies \\ Anwer:\ \binom{4}{3} \binom{104}{3} \binom{17}{3}=4*182,104*680=4.95\cdot10^8 different\ schedules\ possible. \end{equation*}\]dules possible.

\end{equation*}

Q6 <- formatC(round(choose(4,3) * choose(104,3) * choose(17,3), -2), format="e")

print(paste0("The different schedules are possible are: ",Q6))
## [1] "The different schedules are possible are: 4.9532e+08"

Question 7. An English teacher needs to pick 13 books to put on his reading list for the next school year, and he needs to plan the order in which they should be read. He has narrowed down his choices to 6 novels, 6 plays, 7 poetry books, and 5 nonfiction books.

Step 1. If he wants to include no more than 4 nonfiction books, how many different reading schedules are possible? Express your answer in scientific notation rounding to the hundredths place.

Q7_S1 <- formatC(round((choose(5,0)*choose(19,13)) + (choose(5,1)*choose(19,12)) + (choose(5,2)*choose(19,11)) + (choose(5,3)*choose(19,10)) + (choose(5,4)*choose(19,9)), -2), format="e")

print(paste0("The total different reading schedules possible if he wants to include no more than 4 nonfiction books are : ",Q7_S1))
## [1] "The total different reading schedules possible if he wants to include no more than 4 nonfiction books are : 2.4206e+06"

Step 2. If he wants to include all 6 plays, how many different reading schedules are possible? Express your answer in scientific notation rounding to the hundredths place.

If the teacher wants to include all six plays, then he has to pick 7 more books out of the 6 novels, 7 poetry books, and 5 nonfiction books. The total number of ways to choose 7 books out of 18 is:

\[\begin{equation*} \binom{18}{7} =\frac{18!}{(18-7)!7!} \\ =\frac{18!}{7!11!} =31824 =\ 3.1824e+04 \end{equation*}\]

Expressing this number in scientific notation and rounding to the hundredths place gives: \[3.18\times 10^{4}\] Therefore, there are approximately 3.1824e+04 different reading schedules possible.

Q7_S2 <- formatC(round(factorial(6) * (factorial(6 + 7 + 5)/factorial(6 + 7 + 5-7)), -2), format="e")


print(paste0("The total different reading schedules possible if he wants to include all 6 plays are : ",Q7_S2))
## [1] "The total different reading schedules possible if he wants to include all 6 plays are : 1.1548e+11"

Question 8. Zane is planting trees along his driveway, and he has 5 sycamores and 5 cypress trees to plant in one row. What is the probability that he randomly plants the trees so that all 5 sycamores are next to each other and all 5 cypress trees are next to each other? Express your answer as a fraction or a decimal number rounded to four decimal places.

There are a total of 10 trees to plant, and we want to calculate the probability that all 5 sycamores are together and all 5 cypress trees are together.

First, we need to calculate the total number of ways to arrange the 10 trees in a row, which is \[10! = 3,628,800\]

We can count the total number of ways to arrange the 10 trees and then count the number of arrangements where all 5 sycamores and all 5 cypress trees are together.

We can treat the 5 sycamores as a single entity and the 5 cypress trees as another single entity. This reduces the problem to arranging 2 entities, which can be done in 2! = 2 ways (either sycamores first or cypress trees first).

Within each group of trees, there are 5! = 120 ways to arrange the individual trees. So the total number of arrangements where all 5 sycamores and all 5 cypress trees are together is:

\[ 2 x 5! x 5! = 2 x 120 x 120 = 28,800 \]

To count the total number of arrangements of 10 trees, we can simply calculate \[10! = 3,628,800\].

P = number of favorable outcomes / total number of outcomes P = 2,880 / 3,628,800

Therefore, the probability of randomly planting the trees so that all 5 sycamores are next to each other and all 5 cypress trees are next to each other is: \[28,800 / 3,628,800 = 0.0079\] (rounded to four decimal places) or \[ 79/10000\].

# each block of five can be arranged in two ways so total is multiplied by 2. The total permutations of all 10 tress is calculated.
prob <- round((2*factorial(5)*factorial(5))/factorial(10),4)

print(paste0('The probability that he randomly plants the trees so that all 5 sycamores are next to each other and all 5 cypress trees are next to each other are ', prob,''))
## [1] "The probability that he randomly plants the trees so that all 5 sycamores are next to each other and all 5 cypress trees are next to each other are 0.0079"

Question 9. If you draw a queen or lower from a standard deck of cards, I will pay you $4. If not, you pay me $16. (Aces are considered the highest card in the deck.)

Step 1. Find the expected value of the proposition. Round your answer to two decimal places. Losses must be expressed as negative values.

Q9_S1 <- round((4* (44/52)) + (-16 * (8/52)),2)

print(paste0('The expected value of the proposition is: ', Q9_S1))
## [1] "The expected value of the proposition is: 0.92"

Step 2. If you played this game 833 times how much would you expect to win or lose? Round your answer to two decimal places. Losses must be expressed as negative values

Q9_S2 <- round(((4* (44/52)) + (-16 * (8/52))) * 833,2)

print(paste0('If I played this game 833 times I would you expect to win or lose $', Q9_S2))
## [1] "If I played this game 833 times I would you expect to win or lose $768.92"