Question 1

What is the probability of rolling a sum of 12 on three rolls of six-sided dice? Express your answer as a decimal number only. Show your R code.

diceCombos <- expand.grid(d1 = 1:6, d2 = 1:6, d3 = 1:6) # all combinations of rolling 3 dice
allSums <- rowSums(diceCombos) # Sum of each row in a vector, same length as # of combos
sumTo12 <- which(allSums==12) # creates vector from allSums the equal 12
pOf12 = length(sumTo12)/length(diceCombos) # P(3 dice summing to 12) = length of sumTo12 divided by length of all combinations
pOf12
## [1] 8.333333

Question 2

A newspaper company classifies its customers by gender and location of residence. The research department has gathered data from a random sample of customers. The data is summarized in the table below. What is the probability that a customer is male and lives in ‘Other’ or is female and lives in ‘Other’? Express your answer as a decimal number only. Show your R code. Hint: create the matrix above in R, use rowSums and colSums to generate marginal probabilities.

newsData <- matrix(c(200,300,200,100,100,200,200,100,200,100),nrow=5, ncol=2, byrow = TRUE)
rownames(newsData) <- c("Apartment", "Dorm", "With Parent(s)", "Sorority/Fraternity House", "Other")
colnames(newsData) <- c("Males","Females")
pGender <- colSums(newsData, na.rm=FALSE,1) # Vector of Gender Probabilities
pGender
##   Males Females 
##     900     800
pResidence <- rowSums(newsData, na.rm=FALSE,1) # Vector of Residence Probabilities
pResidence
##                 Apartment                      Dorm            With Parent(s) 
##                       500                       300                       300 
## Sorority/Fraternity House                     Other 
##                       300                       300
totalCust <- sum(pResidence) # Total Number of Customers
pMorFinOther <- pResidence[5]/totalCust # customer is male and lives in 'Other' or is female and lives in 'Other'
pMorFinOther
##     Other 
## 0.1764706

Question 3

  1. Two cards are drawn without replacement from a standard deck of 52 playing cards. What is the probability of choosing a diamond for the second card drawn, if the first card, drawn without replacement, was a diamond? Express your answer as a decimal number only. Show your R code.
numberCards <- 52
pFirstDiamond <- 1 / (numberCards/4) # 1 out of All Diamonds (52/4)
pSecondDiamond <- 1 / ((numberCards-1)/4) # One Less Diamond
pSecondDiamond
## [1] 0.07843137

X—XX— X—XX—X—XX—X—XX— X—XX <!- The next few questions are about permutation, combination, and factorials. Permutation relates to the act of arranging all the members of a set into some sequence or order. EG. Arranging people, digits, numbers, alphabets, letters, and colours are examples of permutations. However, combination is a way of selecting items from a collection, such that (unlike permutations) the order of selection does not matter. EG. Selection of menu, food, clothes, subjects, the team are examples of combinations. Basic History and Comparison Chart Formulas summary (no repeats is the more common usage)- Also, the factorial function (symbol: !) just means to multiply a series of descending natural numbers. Examples: • 4! = 4 × 3 × 2 × 1 = 24 • 7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5,040 • 1! = 1 Note: it is generally agreed that 0! = 1. It may seem funny that multiplying no numbers together gets us 1, but it helps simplify a lot of equations. How to implement them in R - https://davetang.org/muse/2013/09/09/combinations-and-permutations-in-r/ –>

Question 4

A coordinator will select 10 songs from a list of 20 songs to compose an event’s musical entertainment lineup. How many different lineups are possible? Show your R code. install.packages(‘gtools’) library(gtools)

songCombos <- factorial(20) / (factorial(20-10)) # Permutation, No Repeats
songCombos
## [1] 670442572800

Question 5

You are ordering a new home theater system that consists of a TV, surround sound system, and DVD player. You can choose from 20 different TVs, 20 types of surround sound systems, and 18 types of DVD players. How many different home theater systems can you build? Show your R code.

theaterCombos <- 20*20*18
theaterCombos
## [1] 7200

Question 6

  1. A doctor visits her patients during morning rounds. In how many ways can the doctor visit 10 patients during the morning rounds? Show your R code.
drVisits <- factorial(10) # Combination, No Repeats
drVisits
## [1] 3628800

Question 7

  1. If a coin is tossed 7 times, and then a standard six-sided die is rolled 3 times, and finally a group of four cards are drawn from a standard deck of 52 cards without replacement, how many different outcomes are possible? Show your R code.
nTosses <- 7
nRolls <- 3
nDraws <- 4
coinSet <- 2
diceSet <- 6
cardSet <- 52
coinOutcomes <- coinSet^nTosses # Combination, Repeats
diceOutcomes <- diceSet^nRolls # Combination, Repeats
cardOutcomes <- factorial(cardSet) / (factorial(nDraws) * (factorial(cardSet-nDraws))) # Combinations, No Repeats
totalOutcomes <- coinOutcomes * diceOutcomes * cardOutcomes
totalOutcomes
## [1] 7485004800

Question 8

  1. In how many ways may a party of four women and four men be seated at a round table if the women and men are to occupy alternate seats. Show your R code.
permOfMW <- factorial(4) / (factorial(4 - 2)) # Get How many permutations of MW of 4 pick 2
# I don't think we need this one, as the MW on a round table will satisfy the problem
permOfWM <- factorial(4) / (factorial(4 - 2)) # Get How many permutations of WM of 4 pick 2
seatCombo <- factorial(1 + 4 -1) / factorial(1) * factorial(4 - 1) # Get How many Combos of 4 sets of MW
#totalSeatCombos <- permOfMW * permOfWM * seatCombo # multiply results
totalSeatCombos <- permOfMW * seatCombo
totalSeatCombos
## [1] 1728

Question 9

  1. BAYESIAN PROBABILITY An opioid urinalysis test is 95% sensitive for a 30-day period, meaning that if a person has actually used opioids within 30 days, they will test positive 95% of the time P( + | User) =.95. The same test is 99% specific, meaning that if they did not use opioids within 30 days, they will test negative P( - | Not User) = .99. Assume that 3% of the population are users. Then what is the probability that a person who tests positive is actually a user P(User | +)? Show your R code. You may use a tree, table, or Bayes to answer this problem.

Question 10

  1. You have a hat in which there are three pancakes. One is golden on both sides, one is brown on both sides, and one is golden on one side and brown on the other. You withdraw one pancake and see that one side is brown. What is the probability that the other side is brown? Explain

P(other side brown) = 1/2 = 0.5

Explanation: two pancakes have a brown side, you pulled out one of them, so you have a 50% chance the other side is brown