Problem 1

So it can be RRRRR or GRRRR (no order). I used paper and by hand, using binomial distribution:

Using R:

green_jellybeans <- 5
red_jellybeans <- 7

# no green jellybeans are withdrawn (5 reds)
ways_1 <- 1

# 1 green jellybean is withdrawn, and 4 reds
ways_to_choose_green <- green_jellybeans

# ways to choose 4 red out of 7
ways_to_choose_red <- choose(red_jellybeans, 4)

# number of ways for possibility 2
ways_2 <- ways_to_choose_green * ways_to_choose_red

total_ways <- ways_1 + ways_2

print(total_ways)
## [1] 176

Problem 2:

So it can be RRRRR or SRRRR. Again, by hand I can use the binomial distribution:

Using R:

sen <- 14
reps <- 13

# 4 reps and 1 senator
case1 <- choose(reps, 4) * choose(sen, 1)

# 5 members are reps
case2 <- choose(reps, 5)

total_ways <- case1 + case2

print(total_ways)
## [1] 11297

Problem 3:

Using R:

coin <- 2**5

die <- 6**2

cards <- choose(52,3)

total_ways <- coin * die * cards

total_ways
## [1] 25459200

Problem 4:

There are 3 possible scenarios here:

Another way:

Another way: using simulations in R Using R:

#Method 1:
((4/52)*(3/51)*(2/50)) + ((4/52)*(3/51)*(48/50)*3) + ((4/52)*(48/51)*(47/50)*3)
## [1] 0.2173756
#Method 2
Pn <- ((48/52)*(47/51)*(46/50))
1-Pn
## [1] 0.2173756
#Method 3: simulation
set.seed(123) # seed for reproducibility
deck <- rep(1:13, 4) # a deck of cards
simulations <- 100000
draws_with_3 <- 0 # Counter

for (i in 1:simulations) {
  draw <- sample(deck, 3, replace = FALSE)
  if (3 %in% draw) { # Check
    draws_with_3 <- draws_with_3 + 1
  }
}

probability <- draws_with_3 / simulations
probability
## [1] 0.21732

Problem 5:

docs <- 17
mys <- 14
total <- docs + mys

# 1
combos <- choose(total, 5)

# 2
# only docs
docs_only <- choose(docs, 5)
at_least_1_mystery <- combos - docs_only
# we can also get the at least 1 mystery by calculating 1 - probability of all 5 docs

combos
## [1] 169911
at_least_1_mystery
## [1] 163723

Problem 6

If there are going to be 9 symphonies, with equal number between the three composers, then 3 symphonies will be played from each of the composer’s lists. So (using permutations and combinometrics):

possible_combos <- choose(4,3) * choose(104,3) * choose(17,3)

possible_schedules <- factorial(9) * possible_combos

# notation  
sprintf("%.2e", possible_schedules)
## [1] "1.80e+14"

Problem 7

Part1:

Using R, and using combinometrics:

total_fiction <- 6 + 6 + 7

total_schedules <- 0

# number of schedules for each possible number of nonfiction books
for (NF in 0:4) { 
  fiction <- 13 - NF  # remaining out of 13
  total_schedules <- total_schedules + choose(total_fiction, fiction) * choose(5, NF)
}

# notation
sprintf("%.2e", total_schedules)
## [1] "2.42e+06"
# For step 2:
total_fiction_without_PL <- 6 + 7 

total_schedules_step2 <- 0

# schedules for each possible number of nonfiction books (0 to 4)
for (NF in 0:4) { 
  remaining_books <- 7 - NF  # remaining
  total_schedules_step2 <- total_schedules_step2 + choose(total_fiction_without_PL, remaining_books) * choose(5, NF)
}

sprintf("%.2e", total_schedules_step2)
## [1] "3.17e+04"

Problem 8:

The probability we are looking for is the sum of the probabilities of all of the following: CCCCCSSSSS, SCCCCCSSSS, SSCCCCCSSS, SSSCCCCCSS, SSSSCCCCCS, SSSSSCCCCC. Therefore:

possible_6_arrangements <- 6 * factorial(5) * factorial(5)

total_possible_arrangements <- factorial(10)

probability <- possible_6_arrangements / total_possible_arrangements

result <- round(probability, 4)

result
## [1] 0.0238

Problem 9:

I would need to calculate the probabilities of the two outcomes (drawing a queen or lower, and drawing a king or an ace) and their associated payoffs. Drawing a queen or lower would therefore include the cards 2 through 10, Jack, and Queen, which gives us 11 cards per suit.

The expected value (EV):

EV = (P(queen_or_ _lower) × Payoff for queen_or_lower) + (P(king_or_ace) × Payoff for king_or_ace)

So:

prob_queen_or_lower = (11 * 4) / 52
prob_king_or_ace = (2 * 4) / 52

payoff_queen_or_lower = 4
payoff_king_or_ace = -16

# Expected value for one game
expected_value_one_game = (prob_queen_or_lower * payoff_queen_or_lower) + (prob_king_or_ace * payoff_king_or_ace)

# Expected value for 833 games
expected_value_833_games = expected_value_one_game * 833

expected_value_one_game
## [1] 0.9230769
expected_value_833_games
## [1] 768.9231

Using simulations to solve this (just for fun), as I think this is a good case to simulate:

set.seed(123) # for reproducibility 

simulate_game <- function() {
  card <- sample(2:14, 1, replace = TRUE) # 11=Jack, 12=Queen, 13=King, 14=Ace
  if (card <= 12) {
    return(4)
  } else {
    return(-16)
  }
}

simulated_games <- replicate(833, simulate_game())

average_win_loss <- mean(simulated_games)

total_win_loss <- sum(simulated_games)

average_win_loss
## [1] 1.190876
total_win_loss
## [1] 992

It’s interesting how I got similar results not not quite exactly the same.