format_csn <- function(x){
x <- format(round(as.numeric(x), 0), nsmall=0,
scientific=FALSE, big.mark=",")
x <- as.character(x)
}
calc_permutations <- function(n, r){
perm <- factorial(n) / factorial(n - r)
perm
}
calc_permutations_with_repitition <- function(n, r){
perm <- n^r
perm
}
calc_combinations <- function(n, r){
comb <- factorial(n) / (factorial(r) * factorial(n - r))
comb
}
senators <- LETTERS[seq(1, 14)]
representatives <- letters[seq(1, 13)]
r5 <- calc_combinations(length(representatives), 5)
s1 <- length(senators)
r4 <- calc_combinations(length(representatives), 4)
s1r4 <- s1 * r4
ways <- format_csn(r5 + s1r4)
coin <- c("H", "T")
die <- seq(1, 6)
deck <- c(LETTERS[seq(1, 26)], letters[seq(1, 26)])
c5 <- calc_permutations_with_repitition(length(coin), 5)
di2 <- calc_permutations_with_repitition(length(die), 2)
de3 <- calc_permutations(length(deck), 3)
outcomes <- format_csn(c5 * di2 * de3)
p_zero_3s <- (48 / 52) * (47 / 51) * (46 / 50)
p_at_least_one_3 <- round(1 - p_zero_3s, 4)
movies <- c(LETTERS[seq(1, 17)], letters[seq(1, 14)])
m5 <- format_csn(calc_combinations(length(movies), 5))
There are 169,911 combinations of movies he can rent.
Step 2. How many different combinations of 5 movies can he rent if he wants at least one mystery?
myst <- letters[seq(1, 14)]
docs <- LETTERS[seq(1, 17)]
myst1 <- calc_combinations(length(myst), 1)
docs4 <- calc_combinations(length(docs), 4)
myst2 <- calc_combinations(length(myst), 2)
docs3 <- calc_combinations(length(docs), 3)
myst3 <- calc_combinations(length(myst), 3)
docs2 <- calc_combinations(length(docs), 2)
myst4 <- calc_combinations(length(myst), 4)
docs1 <- calc_combinations(length(docs), 1)
myst5 <- calc_combinations(length(myst), 5)
combs <- format_csn(sum(myst1, docs4, myst2, docs3, myst3, docs2, myst4,
docs1, myst5))
B <- 4
B_perms <- calc_permutations(B, 3)
H <- 104
H_perms <- calc_permutations(H, 3)
M <- 17
M_perms <- calc_permutations(M, 3)
schedules <- formatC(B_perms * H_perms * M_perms, format = "e", digits = 2)
schedules <- unlist(as.list(strsplit(schedules, "e\\+")))
NF <- 5
Fic <- 19
NF4 <- calc_permutations(NF, 4)
Fic9 <- calc_permutations(Fic, 9)
NF3 <- calc_permutations(NF, 3)
Fic10 <- calc_permutations(Fic, 10)
NF2 <- calc_permutations(NF, 2)
Fic11 <- calc_permutations(Fic, 11)
NF1 <- calc_permutations(NF, 1)
Fic12 <- calc_permutations(Fic, 12)
Fic13 <- calc_permutations(Fic, 13)
reading_lists <- formatC(sum(NF4, Fic9, NF3, Fic10, NF2, Fic11, NF1, Fic12, Fic13), format = "e", digits = 2)
reading_lists <- unlist(as.list(strsplit(reading_lists, "e\\+")))
There are \(1.96 x 10^{14}\) possible 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.
Plays <- 6
Other <- 18
Plays6 <- calc_permutations(Plays, 6)
Other7 <- calc_permutations(Other, 7)
reading_lists2 <- formatC(sum(Plays6, Other7), format = "e", digits = 2)
reading_lists2 <- unlist(as.list(strsplit(reading_lists2, "e\\+")))
p5syc5cyp = (5 / 10) * (4 / 9) * (3 / 8) * (2 / 7) * (1 / 6)
p5cyp5syc = (5 / 10) * (4 / 9) * (3 / 8) * (2 / 7) * (1 / 6)
p = round(sum(p5syc5cyp, p5cyp5syc), 4)
lose <- (8 / 52) * -16
win <- (44 / 52) * 4
exp_val <- round(sum(lose, win), 2)
The expected value is $0.92.
x <- exp_val * 833
I would expect to win $766.36.