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?
# If the number of Greens (G) is less than 2, then that means G = 0 or G = 1. Another way of saying this, is from 5 jellybeans, we want at least 4 Red beans (R), so R = 4 or R = 5. So P(G<2) is the same as P(R>=4). This is P(R=4) + P(R=5). However, this is sampling without replacement and so the probability of choosing a given jellybean changes as we're lowering the amount of finite beans in the bag.
# P(R=4) = (7/12)*(6/11)*(5/10)*(4/9)*(5/8)
# P(R=5) = (7/12)*(6/11)*(5/10)*(4/9)*(3/8)
# P(G=0) = P(R=5)
# P(G=1) = P(R=4)
# We're choosing 5 random jellybeans out of 12, in a way identical to the Hypergeometric distribution. 
# P(R=4)  = (7c4)*(5c1) / (12c5) = choose(7,4)*choose(5,1) / choose(12,5)
# P(R=5)  = (7c5)*(5c0) / (12c5) = choose(7,5)*choose(5,0) / choose(12,5)


# P(R=4) = P(G=1)
choose(7,4)*choose(5,1) / choose(12,5) #0.2209596
## [1] 0.2209596
#dhyper(red beans drawn, total red beans, green beans, beans drawn)
dhyper(4,7,5,5) #0.2209596
## [1] 0.2209596
# P(R=5) = P(G=0)
choose(7,5)*choose(5,0) / choose(12,5) #0.02651515
## [1] 0.02651515
#dhyper(red beans drawn, total red beans, green beans, beans drawn)
dhyper(5,7,5,5) #0.02651515
## [1] 0.02651515
# Alternatively, P(R=4) + P(R=5)
sum(dhyper(4:5,7,5,5)) #0.2474747 = 0.2209596 + 0.02651515
## [1] 0.2474747
# nCk = n! / (k! * (n-k)!)
# However, while we got the probabilities, we just want the total number of ways to have less than 2 greens from 5 total beans drawn
choose(7,4)*choose(5,1) + choose(7,5)*choose(5,0) # 196
## [1] 196

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?
# Similar to the prior question, we want 4 or 5 Reps from 5 people chosen
choose(13,4)*choose(14,1) + choose(13,5)*choose(14,0) #11297
## [1] 11297

3) If a coin is tossed 5 times, and then a standard six-sided die is rolled 2 times, and finally a group of 3 cards are drawn from a standard deck of 52 cards without replacement, how many different outcomes are possible?
# coin  = 2**5
# d6 = 6**2
# 3 cards from deck of 52 = choose(52,3)

2**5 * 6**2 * choose(52,3)
## [1] 25459200

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.
# P(one 3)
choose(48,2)*choose(4,1) / choose(52,3)  #0.2041629
## [1] 0.2041629
#dhyper(3's drawn, total 3's, not 3's, cards drawn)
dhyper(1,4,48,3) #0.2041629
## [1] 0.2041629
# P(two 3's)
choose(48,1)*choose(4,2) / choose(52,3) # 0.01303167
## [1] 0.01303167
#dhyper(3's drawn, total 3's, not 3's, cards drawn)
dhyper(2,4,48,3) # 0.01303167
## [1] 0.01303167
# P(three 3's)
choose(48,0)*choose(4,3) / choose(52,3) #0.0001809955
## [1] 0.0001809955
#dhyper(3's drawn, total 3's, not 3's, cards drawn)
dhyper(3,4,48,3) #0.0001809955
## [1] 0.0001809955
# Alternatively
sum(dhyper(1:3,4,48,3)) #0.2173756
## [1] 0.2173756

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?

choose(31,5)
## [1] 169911
  • There are 169,911 different combinations

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

# This is the same as the number of total combinations - the ways with 0 mysteries
choose(14,0)*choose(17,5) #There are 6188 ways where there are 0 mysteries
## [1] 6188
169911 - 6188
## [1] 163723
  • There are 163,723 different outcomes with at least 1 mystery.

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.
# Here, the order matters and we need 3 of each symphony so they're played equally

# Brahms
Brahms <-choose(4,3) #4
# Haydn
Haydn <- choose(104,3) #182104
# Mendelssohn
Mendelssohn <- choose(17,3) #680

# Total number of ways to play 9 symphonies
choose(4+104+17,9) #1.529027e+13
## [1] 1.529027e+13
final <- Brahms * Haydn * Mendelssohn
format(final, scientific = TRUE)
## [1] "4.953229e+08"
# There are 4.95 x 10^8 possible ways to choose the songs, but we can order them differently.

# We'll play 9 songs, so final * 9!
format(final * factorial(9), scientific = TRUE)
## [1] "1.797428e+14"

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.

# Order matters
novels <- 6
plays <- 6
poetry <- 7
non_fiction <- 5

# We're choosing 13 books, and can have at most 4 nonfiction
# dhyper(nonfiction chosen, total nonfiction, not nonfiction, books chosen)
# This is the probability
sum(dhyper(0:4,5,6+6+7-5,13)) #0.8893189
## [1] 0.8893189
# Total different reading schedules = 2,420,562
schedules <- sum(
choose(non_fiction,0)*choose(novels+plays+poetry,13),
choose(non_fiction,1)*choose(novels+plays+poetry,12), 
choose(non_fiction,2)*choose(novels+plays+poetry,11), 
choose(non_fiction,3)*choose(novels+plays+poetry,10),
choose(non_fiction,4)*choose(novels+plays+poetry,9))

# However, there are 13 ways to order them.
schedules * factorial(13)
## [1] 1.507289e+16
  • There are 1.51 x \(10^{16}\) reading schedules

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 we include all 6 plays, and there are 24 books total
choose(6,6)*choose(18,7) * factorial(13)
## [1] 1.981687e+14
  • There are 1.98 x \(10^{14}\) reading schedules

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.
# To have the 5 sycamores next to each other, they're all in order consecutively. Then the Cypress trees are all next to each other as well.
# The total ways we can order the trees is 10! = 3,628,800
# The total ways we can order grouped trees is 2!*5!*5! = 28,800
(2 * factorial(5) * factorial(5)) / factorial(10)
## [1] 0.007936508

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.

# Queen or lower = +4. P(Queen or lower) = 44 cards
# King or higher = -16. P(King or higher) = P(King|Ace) = 8 cards
4*(44/52) - 16*(8/52)
## [1] 0.9230769
  • The expected value 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.

833 * (4*(44/52) - 16*(8/52))
## [1] 768.9231
  • If I played this game 833 times, I’d expect to win $768.92