# 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
# 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
# coin = 2**5
# d6 = 6**2
# 3 cards from deck of 52 = choose(52,3)
2**5 * 6**2 * choose(52,3)
## [1] 25459200
# 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
Step 1) How many different combinations of 5 movies can he rent?
choose(31,5)
## [1] 169911
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
# 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"
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
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
# 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
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
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