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.
p <- expand.grid(rep(list(1:6), 3))
sum1<-rowSums(p)
rollsuccess<- sum(sum1==12)
numofroll<- length(sum1)
p1<- rollsuccess/numofroll
print(p1)
## [1] 0.1157407

the probability of rolling a sum of 12 on three rolls of six-sided dice is 0.1157407.

  1. 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.
numofmale <- 200
numoffemale <- 100
totalcustomer = 200+300+200+100+100+200+200+100+200+100
p2 <- (numofmale/totalcustomer) + (numoffemale/totalcustomer)
print(p2)
## [1] 0.1764706

the probability that a customer is male and lives in ‘Other’ or is female and lives in ’Other is 0.1764706.

3.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.

diamond <- 13-1
card <- 52-1
p3  <- diamond/card
print(p3)
## [1] 0.2352941

the probability of choosing a diamond for the second card is 0.2352941.

  1. 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.
p4 <- function (a,b){
  return(factorial(a)/factorial(a - b))
}
p4(20,10)
## [1] 670442572800

There are 670442572800 lineups are possible.

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.

p5 <- function (a,b){
  return(factorial(a)/factorial(a - b))
}
p5(20,1)*p5(20,1)*p5(18,1)
## [1] 7200

There are 7200 home theater systems can be build.

  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.
p6 <- factorial(10)
print(p6)
## [1] 3628800

There are 3628800 ways that doctor can visit 10 patients during the morning.

7.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.

coin <- 7
die <- 3
p7 <- function (a,b){
  return(factorial(a)/factorial(a - b))
}
total <- 2^coin * 6^die * p7(52,4)
print(total)
## [1] 179640115200

There are 179640115200 outcomes are possible.

  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.
male <- 4
female <- 4
p8 <- factorial(male-1)*factorial(female)
print(p8)
## [1] 144

There are 144 ways for seated.

  1. 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
P_user <- 0.95
P_not <- 0.99
user <- 0.03
# find P(+)
P_positive <- (P_user*user)+(1-P_not)*(1-user)
# Apply Bayes Theorem
p9 <- (P_user*user)/P_positive
print(p9)
## [1] 0.7460733

the probability that a person who tests positive is 0.7460733.

  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_brownA <- 0
P_browmB <- 0.5
P_brownC <- 1
P_choice <- 1/3
p_brown <-(P_browmB * P_choice)/((P_brownA * P_choice+ P_browmB * P_choice + P_brownC* P_choice))
p10 <-(1-p_brown)
print(p10)
## [1] 0.6666667

the probability that the other side is brown is 0.6666667.