Question 1

round(1/540,4)
## [1] 0.0019

Question 2

toppings <- c('A', 'C')
meats <- c('E','T')
dressings <- c('F','V')
expand.grid(x=toppings, y=meats, z=dressings)
##   x y z
## 1 A E F
## 2 C E F
## 3 A T F
## 4 C T F
## 5 A E V
## 6 C E V
## 7 A T V
## 8 C T V

Question 3

deckOfCards <- CombPairs(x=c(2:10,'A','J','Q','K'), y=c('H', 'C','S','D'))
names(deckOfCards) <- c('value', 'suit')
total <- nrow(deckOfCards)
valid <- nrow(deckOfCards[deckOfCards$value %in% c(2:10) & deckOfCards$suit == 'H',])
round(valid/total, 4)
## [1] 0.1731

Question 4

dice <- CombPairs(x=1:6, y=1:6)
names(dice) <- c('die1', 'die2')
total <- nrow(dice)
valid <- nrow(dice[dice$die1 + dice$die2 < 6, ])
round(valid/total, 4)
## [1] 0.2778

Question 5

round(sum(233, 159, 102, 220, 250)/2001, 4)
## [1] 0.4818

Question 6

card1 <- nrow(deckOfCards[deckOfCards$suit == 'C',])
card2 <- nrow(deckOfCards[deckOfCards$suit %in% c('C','S'),])
card3 <- nrow(deckOfCards[deckOfCards$value %in% c('A','J','Q','K'),])
round((card1+card2+card3)/(nrow(deckOfCards)*3), 4)
## [1] 0.3526

Question 7

round(13/51, 4)
## [1] 0.2549

Question 8

round(13/52*12/51, 4)
## [1] 0.0588

Question 9

total <- sum(12, 19, 12, 7, 12, 15, 4, 4)
firstPick <- 4 / total
secondPick <- 12 / (total-1)
round(firstPick*secondPick, 4)
## [1] 0.0067

Question 10

a

maleNoGrad <- 141
maleGrad <- 52
femaleGrad <- 50
femaleNoGrad <- 57
round(maleGrad/(maleNoGrad+maleGrad),4)
## [1] 0.2694

b

round(maleGrad/(maleGrad+femaleGrad),4)
## [1] 0.5098

Question 11

sprintf('There are %s value meal packages', 6*5*3)
## [1] "There are 90 value meal packages"

Question 12

sprintf('There are %s different orders to visit the patients.', factorial(5))
## [1] "There are 120 different orders to visit the patients."

Question 13

Assuming order doesn’t matter

sprintf('%s different sets of songs can be chosen', choose(8,5))
## [1] "56 different sets of songs can be chosen"

Question 14

factorial(9)/(factorial(3)*factorial(5)*factorial(1))
## [1] 504

Question 15

sprintf('There are %s different combinations of toppings', choose(14, 6))
## [1] "There are 3003 different combinations of toppings"

Question 16

sprintf('There are %s different combinations of 3 card hands', 52*51*50)
## [1] "There are 132600 different combinations of 3 card hands"

Question 17

sprintf('There are %s different combinations of setups', 12*9*5)
## [1] "There are 540 different combinations of setups"

Question 18

sprintf('There are %s different possible passwords', 26*25*24*23*22*5*4*3)
## [1] "There are 473616000 different possible passwords"

Question 19

perm <- function(n, r){ factorial(n) / factorial(n-r)}
perm(9,4)
## [1] 3024

Question 20

choose(11, 8)
## [1] 165

Question 21

perm(12,8) / choose(12, 4)
## [1] 40320

Question 22

sprintf('There are %s different permutations of cabinets.', perm(13, 7))
## [1] "There are 8648640 different permutations of cabinets."

Question 23

Assuming capital P and lowercase p are different

sprintf('There are %s different permutations of Population.', factorial(10)/factorial(2))
## [1] "There are 1814400 different permutations of Population."

Question 24

a

expectedValues <- data.frame(5:9, c(0.1,0.2,0.3,0.2,0.2))
names(expectedValues) <- c('x', 'pOfX')
E <- sum(expectedValues$x*expectedValues$pOfX)
round(E, 1)
## [1] 7.2

b

V <- sum((expectedValues$x - E)^2*expectedValues$pOfX)
round(V,1)
## [1] 1.6

c

SD <- sqrt(V)
round(SD,1)
## [1] 1.2

d

round(pnorm(9, E, SD), 1)
## [1] 0.9

e

round(1-pnorm(7, E, SD), 1)
## [1] 0.6

Question 25

a

success <- dbinom(3, size=3, prob=188/376)
E <- success*23 - (1-success)*4
round(E,2)
## [1] -0.62

b

sprintf('I would expected to end up with %s dollars', E*994)
## [1] "I would expected to end up with -621.25 dollars"

Question 26

a

success <- pbinom(8, 11, 0.5)
E <- success*1-(1-success)*7
round(E,2)
## [1] 0.74

b

sprintf('I would expected to end up with %s dollars', E*615)
## [1] "I would expected to end up with 454.04296875 dollars"

Question 27

success <- (13*12)/(52*51)
E <- success*583 - (1-success)*35
round(E, 2)
## [1] 1.35
sprintf('I would expected to end up with %s dollars', E*632)
## [1] "I would expected to end up with 855.058823529415 dollars"

Question 28

round(pbinom(2, 10, .3), 3)
## [1] 0.383

Question 29

sprintf("One would expect %s broken bulbs", 5*.3)
## [1] "One would expect 1.5 broken bulbs"

Question 30

ppois(6, 5.5, lower=FALSE)
## [1] 0.313964

Question 31

ppois(5, 5.7, lower=FALSE)
## [1] 0.5050151

Question 32

ppois(1, 0.4*7)
## [1] 0.2310782

Question 33

numer <- choose(19,8) * choose(6,0) + choose(19,7)*choose(6,1)
denom <- choose(25,8)
round(1- numer/denom, 3)
## [1] 0.651

Question 34

numer <- sum(choose(15,0:6)*choose(10,6:0))
denom <- choose(25,8)
round(numer/denom, 3)
## [1] 0.164