1. There are 540 identical plastic chips numbered 1 through 540 in a box. What is the probability of reaching into the box and randomly drawing the chip numbered 505? Express your answer as a fraction or a decimal number rounded to four decimal places.

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

2. Write out the sample space for the given experiment. Separate your answers using commas. When deciding what you want to put into a salad for dinner at a restaurant, you will choose one of the following extra toppings: asparagus, cheese. Also, you will add one of following meats: eggs, turkey. Lastly, you will decide on one of the following dressings: French, vinaigrette. (Note: Use the following letters to indicate each choice: A for asparagus, C for cheese, E for eggs, T for turkey, F for French, and V for vinaigrette.)

perms <-  expand.grid(list(c("A", "C"), c("E", "T"),c("F","V")))
ans <- paste(perms[,1], perms[,2], perms[,3], collapse=", ")
ans
[1] "A E F, C E F, A T F, C T F, A E V, C E V, A T V, C T V"

3. A card is drawn from a standard deck of 52 playing cards. What is the probability that the card will be a heart and not a face card? Write your answer as a fraction or a decimal number rounded to four decimal places.

S <- cards()
A <- subset(S, suit == "Heart")
B <- subset(S, rank %in% c("A", 1:10))
ans <- intersect(A,B)
round(nrow(ans)/nrow(S), 4)
[1] 0.1923

4. A standard pair of six-sided dice is rolled. What is the probability of rolling a sum less than 6? Write your answer as a fraction or a decimal number rounded to four decimal places.

ss <- rolldie(2)
ss$sum <- ss[,1] + ss[,2]
ss$less_than_6 <- ss$sum < 6
freqT <- count(ss$less_than_6)
round(freqT[2,2]/sum(freqT[,2]), 4)
[1] 0.2778

5. A pizza delivery company classifies its customers by gender and location of residence. The research department has gathered data from a random sample of 2001 customers. The data is summarized in the table below. What is the probability that a customer is male? Write your answer as a fraction or a decimal number rounded to four decimal places.

myfile <- "https://raw.githubusercontent.com/kylegilde/cuny-winter-math/master/Q5%2520Table.csv"
myURL <- getURL(myfile)
Q5_table <- read.csv(text = myURL, sep = ",")
round(sum(Q5_table$Males)/sum(Q5_table),4)
[1] 0.4818

6. Three cards are drawn with replacement from a standard deck. What is the probability that the first card will be a club, the second card will be a black card, and the third card will be a face card? Write your answer as a fraction or a decimal number rounded to four decimal places.

Deck <- cards()

A <- subset(Deck, suit == "Club")
PA <- nrow(A)/nrow(Deck)
B <- subset(Deck, suit %in% c("Club","Spade"))
PB <- nrow(B)/nrow(Deck)
C <- subset(Deck, rank %in% c("K", "Q", "J"))
PC <- nrow(C)/nrow(Deck)

PABC <- round(PA * PB * PC, 4)

PABC
[1] 0.0288

7. Two cards are drawn without replacement from a standard deck of 52 playing cards. What is the probability of choosing a spade for the second card drawn, if the first card, drawn without replacement, was a heart? Write your answer as a fraction or a decimal number rounded to four decimal places.

Deck <- cards()
PBGA <- nrow(subset(Deck, suit == "Spade"))/(nrow(Deck) - 1)
round(PBGA, 4) # 13/51
[1] 0.2549

8. Two cards are drawn without replacement from a standard deck of 52 playing cards. What is the probability of choosing a heart and then, without replacement, a red card? Write your answer as a fraction or a decimal number rounded to four decimal places.

Deck <- cards()
PA <- nrow(subset(Deck, suit == "Heart"))/(nrow(Deck))
PBGA <- (nrow(subset(Deck, suit %in% c("Heart","Diamond")))  - 1) /(nrow(Deck) - 1)
round(PA * PBGA, 4)
[1] 0.1225

9. There are 85 students in a basic math class. The instructor must choose two students at random. What is the probability that a junior female and then a freshmen male are chosen at random? Write your answer as a fraction or a decimal number rounded to four decimal places.

myfile <-  "https://raw.githubusercontent.com/kylegilde/cuny-winter-math/master/math%2520class%2520data.csv"
myURL <- getURL(myfile)
Q9_table <- read.csv(text = myURL, sep = ",")

total <- sum(Q9_table$Males, Q9_table$Females)
A <- subset(Q9_table$Females, Q9_table$year == "Juniors")
PA <- A/total 
B <- subset(Q9_table$Males, Q9_table$year == "Freshmen")
PBGA <- B/(total - 1)
round(PA * PBGA, 4) 
[1] 0.0067

10. Out of 300 applicants for a job, 141 are male and 52 are male and have a graduate degree.

round(52/141, 4)
[1] 0.3688
round(26/51, 4)
[1] 0.5098

11. A value meal package at Ron’s Subs consists of a drink, a sandwich, and a bag of chips. There are 6 types of drinks to choose from, 5 types of sandwiches, and 3 types of chips. How many different value meal packages are possible?

6 * 5 * 3 #90
[1] 90

12. A doctor visits her patients during morning rounds. In how many ways can the doctor visit 5 patients during the morning rounds?

factorial(5) #120
[1] 120

13. A coordinator will select 5 songs from a list of 8 songs to compose an event’s musical entertainment lineup. How many different lineups are possible?

nsamp(8,5,ordered=T) #6720
[1] 6720

14. A person rolls a standard six-sided die 9 times. In how many ways can he get 3 fours, 5 sixes and 1 two?

outcome <- c(rep(4, 3), rep(6, 5), 2)
nsamp(length(outcome),length(outcome), ordered = T)/factorial(3)/factorial(5)
[1] 504

15. How many ways can Rudy choose 6 pizza toppings from a menu of 14 toppings if each topping can only be chosen once?

nsamp(14,6) #3003
[1] 3003

16. 3 cards are drawn from a standard deck of 52 playing cards. How many different 3-card hands are possible if the drawing is done without replacement?

nsamp(52,3) #22100
[1] 22100

17. You are ordering a new home theater system that consists of a TV, surround sound system, and DVD player. You can choose from 12 different TVs, 9 types of surround sound systems, and 5 types of DVD players. How many different home theater systems can you build?

12 * 9 *5 #540
[1] 540

18. You need to have a password with 5 letters followed by 3 odd digits between 0 - 9 inclusively. If the characters and digits cannot be used more than once, how many choices do you have for your password?

odds <- c(1,3,5,7,9)
nsamp(length(letters),5, ordered = T) * nsamp(length(odds),3, ordered = T) 
[1] 473616000
#473616000

19. Evaluate the following expression. 9P4

nsamp(9, 4, ordered = T) #3024
[1] 3024

20. Evaluate the following expression. _11 C_8

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

21. Evaluate the following expression. ( _12 P_8)/( _12 C_4 )

nsamp(12, 8, ordered = T)/nsamp(12, 4) #40320
[1] 40320

22. The newly elected president needs to decide the remaining 7 spots available in the cabinet he/she is appointing. If there are 13 eligible candidates for these positions (where rank matters), how many different ways can the members of the cabinet be appointed?

nsamp(13, 7, ordered = T)
[1] 8648640

23. In how many ways can the letters in the word ‘Population’ be arranged?

word <- "Population"
letter_vec <- sapply(unlist(strsplit(word, "")), tolower)
#count(letter_vec)
nsamp(length(letter_vec), length(letter_vec), ordered = T)/factorial(2)/factorial(2) #907200
[1] 907200

24. Consider the following data:

x <- c( 5,  6,  7,  8,  9)
px <- c(0.1,    0.2,    0.3,    0.2,    0.2)
xpx <- x * px
distro <- cbind(x, px, xpx)
distro <- data.frame(distro)
m <- sum(distro$xpx)/sum(distro$px)
round(m, 1) #7.2
[1] 7.2
variance <- round(sum((distro[,1] - m)^2 * distro[,2]/ (sum(distro[,2]))),1) #1.6
variance
[1] 1.6
round(sqrt(variance),1)
[1] 1.3
round(sum(subset(distro[,2], distro[,1] >= 9)),1) #.2
[1] 0.2
round(sum(subset(distro[,2], distro[,1] <= 7)),1) #.6
[1] 0.6

25. Suppose a basketball player has made 188 out of 376 free throws. If the player makes the next 3 free throws, I will pay you $23. Otherwise you pay me $4.

EX <- dbinom(3, 3, .5) * 23 + (1 - dbinom(3, 3, .5)) * -4
round(EX, 2)
[1] -0.62
EX * 994 
[1] -621.25

26. Flip a coin 11 times. If you get 8 tails or less, I will pay you $1. Otherwise you pay me $7.

round(pbinom(8, 11, .5) * 1 + pbinom(8, 11, .5, lower.tail = F) * -7,2) # 0.74
[1] 0.74
round(pbinom(8, 11, .5) * 1 + pbinom(8, 11, .5, lower.tail = F) * -7,2) * 615 # 455.1
[1] 455.1

27. If you draw two clubs on two consecutive draws from a standard deck of cards you win $583. Otherwise you pay me $35. (Cards drawn without replacement.)

P <- dhyper(2,13,39,2)
E_X <- P * 583 + (1 - P) * -35
round(E_X, 2) # 1.35
[1] 1.35
round(E_X, 2) * 632 #853.2 
[1] 853.2

28. A quality control inspector has drawn a sample of 10 light bulbs from a recent production lot. If the number of defective bulbs is 2 or less, the lot passes inspection. Suppose 30% of the bulbs in the lot are defective. What is the probability that the lot will pass inspection? (Round your answer to 3 decimal places)

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

29. A quality control inspector has drawn a sample of 5 light bulbs from a recent production lot. Suppose that 30% of the bulbs in the lot are defective. What is the expected value of the number of defective bulbs in the sample? Do not round your answer.

5 * .3
[1] 1.5

30. The auto parts department of an automotive dealership sends out a mean of 5.5 special orders daily. What is the probability that, for any day, the number of special orders sent out will be more than 5? (Round your answer to 4 decimal places)

round(ppois(5, 5.5, lower.tail = F), 4)
[1] 0.4711

31. At the Fidelity Credit Union, a mean of 5.7 customers arrive hourly at the drive-through window. What is the probability that, in any hour, more than 4 customers will arrive? (Round your answer to 4 decimal places)

round(ppois(4, 5.7, lower.tail = F), 4) # 0.6728 
[1] 0.6728

32. The computer that controls a bank’s automatic teller machine crashes a mean of 0.4 times per day. What is the probability that, in any 7-day week, the computer will crash no more than 1 time? (Round your answer to 4 decimal places)

round(ppois(1, 2.8), 4) #.2311
[1] 0.2311

33. A town recently dismissed 8 employees in order to meet their new budget reductions. The town had 6 employees over 50 years of age and 19 under 50. If the dismissed employees were selected at random, what is the probability that more than 1 employee was over 50? Write your answer as a fraction or a decimal number rounded to three decimal places.

#x, q = white balls are # of successes you want
#m = all possible successes (white balls)
#n = # of non-successes in urn (black balls)
#k = the number of balls drawn from the urn.

q <- 1
m <- 6
n <- 19   
k <- 8
P <- phyper(q, m, n, k, lower.tail = F)
round(P, 3)
[1] 0.651

34. Unknown to a medical researcher, 10 out of 25 patients have a heart problem that will result in death if they receive the test drug. Eight patients are randomly selected to receive the drug and the rest receive a placebo. What is the probability that less than 7 patients will die? Write your answer as a fraction or a decimal number rounded to three decimal places.

q <- 6
m <- 10
n <- 15 
k <- 8
P <- phyper(q, m, n, k)
round(P, 3)
[1] 0.998