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.
library(MASS)
print(paste0("The probability of reaching into the box and randomly drawing the chip numbered 505 is ", fractions(1/540), "."))
## [1] "The probability of reaching into the box and randomly drawing the chip numbered 505 is 1/540."
extraToppings <- c('A', 'C')
meats <- c('E', 'T')
dressings <- c('F', 'V')
for (t in extraToppings){
for (m in meats){
for (d in dressings){
print(paste(t,m,d, sep=','))
}
}
}
## [1] "A,E,F"
## [1] "A,E,V"
## [1] "A,T,F"
## [1] "A,T,V"
## [1] "C,E,F"
## [1] "C,E,V"
## [1] "C,T,F"
## [1] "C,T,V"
# 52 playing cards
# 13 of them are hearts
# 10 of hearts are not a face card
print(paste0("The probability that the card will be a heart and not a face card is ", fractions(10/52), "."))
## [1] "The probability that the card will be a heart and not a face card is 5/26."
die1 <- 1:6
die2 <- 1:6
moreThan6 <- 0
lessThan6 <- 0
for (d1 in die1){
for (d2 in die2){
if(d1 + d2 < 6){
lessThan6 <- lessThan6 + 1
}
moreThan6 <- moreThan6 + 1
}
}
print(paste0("The probability of rolling a sum less than 6 is ", fractions(lessThan6/moreThan6), "."))
## [1] "The probability of rolling a sum less than 6 is 5/18."
| Gender and Residence of Customers | Males | Females |
|---|---|---|
| Apartment | 233 | 208 |
| Dorm | 159 | 138 |
| With Parents(s) | 102 | 280 |
| Sorority/Fraternity House | 220 | 265 |
| Other | 250 | 146 |
What is the probability that a customer is male? Write your answer as a fraction or a decimal number rounded to four decimal places.
males <- c(233, 159, 102, 220, 250)
females <- c(208, 138, 280, 265, 146)
total <- sum(males + females)
print(paste0("The probability that a customer is male is ", fractions(sum(males)/total), "."))
## [1] "The probability that a customer is male is 964/2001."
print(paste0("The probability of a club card is ", fractions(13/52), "."))
## [1] "The probability of a club card is 1/4."
print(paste0("The probability of a black card is ", fractions(26/52), "."))
## [1] "The probability of a black card is 1/2."
print(paste0("The probability of a face card is ", fractions(12/52), "."))
## [1] "The probability of a face card is 3/13."
heart <- 13/52
club <- 13/51
print(paste0("The probability of choosing a spade for the second card drawn, if the first card, drawn without replacement, was a heart is ", fractions((heart*club)/heart), "%."))
## [1] "The probability of choosing a spade for the second card drawn, if the first card, drawn without replacement, was a heart is 13/51%."
heart <- 13/52
red <- 25/51
print(paste0("The probability of choosing a heart and then, without replacement, a red card is ", fractions(heart*red), "."))
## [1] "The probability of choosing a heart and then, without replacement, a red card is 25/204."
| Students in a Basic Math Class | Males | Females |
|---|---|---|
| Freshmen | 12 | 12 |
| Sophomores | 19 | 15 |
| Juniors | 12 | 4 |
| Seniors | 7 | 4 |
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.
jFemale <- 4/85
fMale <- 12/85
print(paste0("The probability that a junior female and then a freshmen male are chosen at random is ", fractions(jFemale*fMale), "."))
## [1] "The probability that a junior female and then a freshmen male are chosen at random is 48/7225."
male <- 141/300
gdMale <- 52/300
gd <- 102/300
print(paste0("The probability that a randomly chosen applicant has a graduate degree, given that they are male is ", fractions(gdMale/male), "."))
## [1] "The probability that a randomly chosen applicant has a graduate degree, given that they are male is 52/141."
print(paste0("The probability that a randomly chosen applicant is male, given that the applicant has a graduate degree is ", fractions(gdMale/gd), "."))
## [1] "The probability that a randomly chosen applicant is male, given that the applicant has a graduate degree is 26/51."
drink <- 6
sandwich <- 5
chips <- 3
print(paste(drink*sandwich*chips, "different value meal packages are possible."))
## [1] "90 different value meal packages are possible."
print(paste("In", factorial(5), "many ways the doctor can visit 5 patients during the morning rounds."))
## [1] "In 120 many ways the doctor can visit 5 patients during the morning rounds."
Permutations <- function(n,r){
factorial(n)/factorial(n-r)
}
print(paste(Permutations(8,5), "different lineups are possible."))
## [1] "6720 different lineups are possible."
fours <- 3
sixes <- 5
two <- 1
rolls <- 9
print(paste(factorial(rolls)/((factorial(fours)*factorial(sixes)*factorial(two))), "ways."))
## [1] "504 ways."
Combinations <- function(n,r){
factorial(n)/(factorial(n-r)*factorial(r))
}
paste(paste("Rudy can choose 6 pizza toppings from a menu of 14 toppings in", Combinations(14,6), "ways."))
## [1] "Rudy can choose 6 pizza toppings from a menu of 14 toppings in 3003 ways."
print(paste(fractions(Combinations(52,3)), "different 3-card hands are possible if the drawing is done without replacement."))
## [1] "22100 different 3-card hands are possible if the drawing is done without replacement."
tv <- 12
sound <- 9
dvd <- 5
print(paste(tv*sound*dvd, "different home theatre systems can be build."))
## [1] "540 different home theatre systems can be build."
print(paste(Permutations(26,5)*Permutations(5,3), "many ways to create the password."))
## [1] "473616000 many ways to create the password."
Permutations(9,4)
## [1] 3024
Combinations(11,8)
## [1] 165
Permutations(12,8)/Combinations(12,4)
## [1] 40320
print(paste(Permutations(13,7), "ways the members of the cabiner can be appointed."))
## [1] "8648640 ways the members of the cabiner can be appointed."
p <- 2
o <- 2
total <-10
print(paste(factorial(10)/(factorial(2)*factorial(2)), "ways the letters in the word 'Population' can be arranged." ))
## [1] "907200 ways the letters in the word 'Population' can be arranged."
| \(x\) | \(p(x)\) |
|---|---|
| 5 | 0.1 |
| 6 | 0.2 |
| 7 | 0.3 |
| 8 | 0.2 |
| 9 | 0.2 |
x <- c(5,6,7,8,9)
px <- c(0.1,0.2,0.3,0.2,0.2)
xpx <- data.frame(x, px)
ev <- sum(xpx$x * xpx$px)
var <- sum((xpx$x - ev)^2 * xpx$px)
sd <- sqrt(var)
ninePlus <- sum((x>=9) * px)
sevenMinus <- sum((x<9) * px)
print(paste0("The expected value is ", round(ev, 1), "."))
## [1] "The expected value is 7.2."
print(paste0("The variance is ", round(var, 1)))
## [1] "The variance is 1.6"
print(paste0("The standard deviation is ", round(sd, 1), "."))
## [1] "The standard deviation is 1.2."
print(paste0("The value of P(X=>9) is ", round(ninePlus, 1), "."))
## [1] "The value of P(X=>9) is 0.2."
print(paste0("The value of P(X<7) is ", round(sevenMinus, 1), "."))
## [1] "The value of P(X<7) is 0.8."
throwIn <- 188
total <- 376
shot1 <- throwIn/total
shot2 <- shot1^2
shot3 <- shot1^3
throwOut <- 1 - shot3
gain <- shot3 * 23
loss <- throwOut * -4
print(paste0("The expected value of the proposition is ", round(gain+loss, 2), "."))
## [1] "The expected value of the proposition is -0.62."
print(paste0("I would lose $", round(gain + loss,2) * 994, ", if this game was played 994 times."))
## [1] "I would lose $-616.28, if this game was played 994 times."
gain <- pbinom(8, size=11, prob=.5)
print(paste0("The expected value of the proposition is ", round(gain*1 + (1-gain)*-7, 2), "."))
## [1] "The expected value of the proposition is 0.74."
print(paste0("If I played this game 615 times, I would win $", round((gain*1 + (1-gain)*-7)*615, 2)))
## [1] "If I played this game 615 times, I would win $454.04"
club1 <- 13/52
club2 <- 12/51
bothClub <- club1 * club2
noClub <- 1 - bothClub
ev <- bothClub*583 + noClub*-35
print(paste0("The expected value of the proposition is ", round(ev, 2), "."))
## [1] "The expected value of the proposition is 1.35."
print(paste0("If I played this game 632 times, I would win $", round(ev*632, 2), "."))
## [1] "If I played this game 632 times, I would win $855.06."
pass <- pbinom(2, size = 10, prob = .3)
print(paste0("The probability that the lot will pass inspection is ", round(pass, 3), "%." ))
## [1] "The probability that the lot will pass inspection is 0.383%."
print(paste0("The expected value of the number of defective bulbs in the sample is ", 5*.3, "."))
## [1] "The expected value of the number of defective bulbs in the sample is 1.5."
print(paste0("The probability that, for any day, the number of special orders sent out will be more than 5 is ", round(ppois(5, 5.5, lower.tail = FALSE),4), "%."))
## [1] "The probability that, for any day, the number of special orders sent out will be more than 5 is 0.4711%."
print(paste0("The probability that, in any hour, more than 4 customers will arrive is ", round(ppois(4, 5.7, lower.tail = FALSE), 4), "%."))
## [1] "The probability that, in any hour, more than 4 customers will arrive is 0.6728%."
print(paste0("The probability that, in any 7-day week, the computer will crash no more than 1 time is ", round(ppois(1, 0.4*7, lower.tail = TRUE), 4), "%."))
## [1] "The probability that, in any 7-day week, the computer will crash no more than 1 time is 0.2311%."
dismissed <- 8
hired <- 6
age1 <- 19
age2 <- 50
hyperDist <- phyper(1, m = hired, n = age1, dismissed, lower.tail = FALSE)
print(paste0("The probability that more than 1 employee was over 50 is ", round((hyperDist), 4), "%."))
## [1] "The probability that more than 1 employee was over 50 is 0.6506%."
heartProb <- 10
drugTest <- 8
test <- 15
patients <- 25
hyperDist <- phyper(6, m = heartProb, n = test, drugTest)
print(paste0("The probability that less than 7 patients will die is ", round((hyperDist), 3), "%."))
## [1] "The probability that less than 7 patients will die is 0.998%."