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?
We can use the binomial coefficient formula to calculate:
\[\left(\begin{array}{l} n \\ j \end{array}\right)=\frac{n !}{j !(n-j) !}\]
There are two ways this can happen:
First let’s calculate choosing 1 green and 5 reds.
# set variables
red <- 7
green <- 5
# 7 reds choose 4
red_7_ch_4 <- factorial(7) / (factorial(4)*factorial((red-4)))
# 5 greens choose 1
green_5_ch_1 <- factorial(5) / (factorial(1)*factorial((green-1)))
# multiply together to get amount of ways
(red_5_green_1 <- red_7_ch_4*green_5_ch_1)
## [1] 175
Second, let’s calculate choosing all 5 as reds
# 7 reds choose 5
(red_7_ch_5 <- factorial(7) / (factorial(5)*factorial((red-5))))
## [1] 21
Now let’s add these together
red_5_green_1 + red_7_ch_5
## [1] 196
Cross check with choose()
functon:
choose(green,1) * choose(red, 4) + choose(red, 5)
## [1] 196
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?
Again this can be solved with the Binomial Coefficient.
If at least 4 must be representatives then here are the options:
# set var
sen <- 14
rep <- 13
# solve for 4 rep
rep_13_ch_4 <- factorial(rep) / (factorial(4)*(factorial(rep-4)))
# solve for 1 sen
sen_14_ch_1 <- factorial(sen) / (factorial(1)*(factorial(sen-1)))
# amount of ways
(rep_4_sen_1 <- rep_13_ch_4*sen_14_ch_1)
## [1] 10010
Let’s solve for 5 representatives and 0 senators
# solve for 5 rep
(rep_13_ch_5 <- factorial(rep) / (factorial(5)*(factorial(rep-5))))
## [1] 1287
Final result
(rep_4_sen_1 + rep_13_ch_5)
## [1] 11297
Cross-check with R
(choose(rep,4)*choose(sen,1)+choose(rep,5))
## [1] 11297
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?
# set variables
coin <- 2
die <- 6
cards <- 52
# coin 5 times
coin_5 <- coin^5
# die 2 times
die_2 <- die^2
# cards 52 choose 3
cards_52_ch_3 <- factorial(52) / (factorial(3)*factorial(cards-3))
# final result
coin_5*die_2*cards_52_ch_3
## [1] 25459200
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.
Let’s break this into multiple parts by first getting the numerator:
# all 3 cards 3
(cards_4_ch_3 <- choose(4,3))
## [1] 4
\[\left(\begin{array}{l} 4 \\ 2 \end{array}\right)*\left(\begin{array}{l} 48 \\ 1 \end{array}\right)=\frac{4 !}{2 !(4-2) !} *\frac{48 !}{1 !(48-1) !}\]
# 2 of 3 cards 3
cards_4_ch_2 <- choose(4,2)
# 1 card something else
cards_48_ch_1 <- choose(48,1)
# multiply
(cards_2_3_1_other <- cards_4_ch_2*cards_48_ch_1)
## [1] 288
\[\left(\begin{array}{l} 4 \\ 1 \end{array}\right)*\left(\begin{array}{l} 48 \\ 2 \end{array}\right)=\frac{4 !}{1 !(4-1) !} *\frac{48 !}{2 !(48-2) !}\]
# 1 of 3 cards 3
cards_4_ch_1 <- choose(4,1)
# 2 cards something else
cards_48_ch_2 <- choose(48,2)
# multiply
(cards_1_3_2_other <- cards_4_ch_1*cards_48_ch_2)
## [1] 4512
Second, let’s get the denominator, any 3 cards:
\[\left(\begin{array}{l} 52 \\ 3 \end{array}\right)=\frac{52 !}{3 !(52-3) !}\]
# any 3 cards
(cards_52_3 <- choose(52,3))
## [1] 22100
Now let’s divide them: \[\frac{\left(\begin{array}{l} 4 \\ 3 \end{array}\right)+\left[\left(\begin{array}{l} 4 \\ 1 \end{array}\right) *\left(\begin{array}{l} 48 \\ 2 \end{array}\right)\right]+\left[\left(\begin{array}{l} 4 \\ 2 \end{array}\right) *\left(\begin{array}{l} 48 \\ 1 \end{array}\right)\right]}{\left(\begin{array}{l} 52 \\ 3 \end{array}\right)}\]
round((cards_4_ch_3 + (cards_4_ch_1*cards_48_ch_2) + (cards_4_ch_2*cards_48_ch_1)) / cards_52_ch_3,4)
## [1] 0.2174
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?
# set variables
mys <- 14
doc <- 17
# set up different scenarios
mys_5 <- choose(mys,5)
doc_5 <- choose(doc,5)
mys_4_doc_1 <- choose(mys,4) * choose(doc,1)
mys_3_doc_2 <- choose(mys,3) * choose(doc,2)
mys_2_doc_3 <- choose(mys,2) * choose(doc,3)
mys_1_doc_4 <- choose(mys,1) * choose(doc,4)
# sum up scenarios
mys_5 + doc_5 + mys_4_doc_1 + mys_3_doc_2 + mys_2_doc_3 + mys_1_doc_4
## [1] 169911
Step 2. How many different combinations of 5 movies can he rent if he wants at least one mystery?
# sum up qualifying secnarios from previous step
mys_5 + mys_4_doc_1 + mys_3_doc_2 + mys_2_doc_3 + mys_1_doc_4
## [1] 163723
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.
# set variables
brahms <- 4
haydn <- 104
mend <- 17
# compute
format(choose(brahms,3) * choose(haydn,3) * choose(mend,3),scientific = T)
## [1] "4.953229e+08"
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.
# set variables
novels <- 6
plays <- 6
poetry <- 7
non_fiction <- 5
all <- novels+plays+poetry+non_fiction
# take all possible ways and subtract when their are 5 non-fiction books with 8
# other books
format(choose(all,13) - choose(non_fiction,5) * choose(all-non_fiction,8),scientific = T)
## [1] "2.420562e+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.
format(choose(plays,6) * choose(all-plays,7),scientific = T)
## [1] "3.1824e+04"
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 only two possible ways for this to happen:
# set var
syc <- 5
cyp <- 5
# get all possible outcomes of 10 choose 5
tree_10_ch_5 <- choose(syc+cyp,5)
# find proportion
round(2/tree_10_ch_5,4)
## [1] 0.0079
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.
# set var
cards <- 52
num_qn_lower <- 44
pay_qn_lower <- 4
if_not <- 16
paste0("$",round(pay_qn_lower * num_qn_lower/cards - if_not * ((cards-num_qn_lower)/cards),2))
## [1] "$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.
paste0("$",833*0.92)
## [1] "$766.36"