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