Please note all answers are at the very bottom of problem sections.
Load libraries and functions:
library(knitr)
There are 540 identical plastic chips numbered 1 through 540 in a box. What is the probability of reaching into a box and randomly drawing the chip numbers 505? Express your answer as a fraction or a decimal number rounded to four decimal places.
round(1/540, 4)
## [1] 0.0019
Write out the sample space for the given experiment. Seperate 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.)
There are \(2^3 = 8\) possible combinations, which can be represented using a structure like a logical truth table:
| Toppings | Meats | Dressing |
|---|---|---|
| A | E | F |
| A | E | V |
| A | T | F |
| A | T | V |
| C | E | F |
| C | E | V |
| C | T | F |
| C | T | V |
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 point rounded to four decimal places.
Looking for the the probability of the intersection of heart and not face card: \(P(H \cap \neg F) = P(H) \times P(\neg F | H)\).
p_H <- 13/52
p_F <- 12/52
p_nF <- 1 - p_F
p_cond <- (p_H * p_nF) / p_H
p_H * p_cond
## [1] 0.1923077
Answer. 0.1923
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?
There are \(6^2 = 36\) possible unique combinations of two six-sided dice. Five of them sum to 6, so:
Answer. \(\frac{5}{36} = 0.1389\)
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.
males <- sum(c(233, 159, 102, 220, 250))
females <- sum(c(208, 138, 280, 265, 146))
males / (males + females)
## [1] 0.4817591
Answer. 0.4818
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.
This is
\[P(c_1=C~\cup~c_2=B~\cup~c_3=F)\] \[= P(c_1=C) \times P(c_2=B) \times (c_3=F)\]
c1 <- 13/52
c2 <- 26/52
c3 <- 12/52
c1 * c2 * c3
## [1] 0.02884615
Answer. 0.0288
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.
This question is asking for
\[P(c_2=S~|~c_1 = H) = \frac{P(c_2=S)~P(c_1 = H)}{P(c_1 = H)}\]
After the heart is drawn, the side of the deck becomes 51, and there are only 12 heart cards, so the probability of drawing a spade on the second draw becomes \(\frac{13}{51}\).
(Note that the probability of drawing this sequence of cards is \(\frac{13}{52} \times \frac{13}{51} = 0.0637\).)
Answer. \(\frac{13}{51}\)
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?
Following the same strategy as above, though with attention to the fact that all hearts are red:
c1 <- 13/52
c2 <- 25/51
c1 * c2
## [1] 0.122549
Answer. 0.1225
There are 58 students in a basic math class. The instructor chose two students at random. What is the probability that a junior female and then a freshman male are chosen at random? Write your answer as a fraction or decimal number rounded to four decimals.
# Construct table (longways)
gender <- c(rep('Male', 4), rep('Female', 4))
class <- rep(c('Freshman', 'Sophomores', 'Juniors', 'Seniors'), 2)
qty <- c(12, 19, 12, 7, 12, 15, 4, 4)
df <- data.frame(gender=gender, class=class, qty=qty)
kable(df)
| gender | class | qty |
|---|---|---|
| Male | Freshman | 12 |
| Male | Sophomores | 19 |
| Male | Juniors | 12 |
| Male | Seniors | 7 |
| Female | Freshman | 12 |
| Female | Sophomores | 15 |
| Female | Juniors | 4 |
| Female | Seniors | 4 |
# Answer problem
p_A <- df$qty[df$gender == 'Female' & df$class == 'Juniors'] / sum(df$qty)
p_B <- df$qty[df$gender == 'Male' & df$class == 'Freshman'] / (sum(df$qty) - 1)
p_A * p_B
## [1] 0.006722689
Answer. 0.0067
Out of 300 applicants for a job, 141 are male and 52 are male and have a graduate degree.
Step 1. What is the probability that a randomly chosen applicant has a graduate degree, given that they are male? Enter your answer as a fraction or a decimal point rounded to four decimal places.
\[P(G ~|~ M) = \frac{P(G ~\cap~ M)}{P(G)}\]
p_M <- 141/300
p_G_M <- 52/300
p_G_M / p_M
## [1] 0.3687943
Answer. 0.3688
Step 2. If 102 of the applicants have graduate degrees, what is the probability that a randomly chosen applicant is male, given that the applicant has a graduate degree? Enter your answer as a fraction or a decimal number rounded to four decimal places.
\[P(M ~|~ G) = \frac{P(M ~\cap~ G)}{P(G)}\]
p_G <- 102/300
p_G_M / p_G
## [1] 0.5098039
Answer. 0.5098
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?
Answer. \(6 \times 5 \times 3 = 90\) possible unique value meal packages
A doctor visits her patients during morning rounds. In how many ways can the doctor visit 5 patients during the morning rounds?
Answer. \(5! =\) 120 possible routes
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?
The number of permutations of 8 songs taken 5 at a time is:
\[ = \frac{8!}{(8 - 5)!}\]
Answer. 6720 possible 5-song sets
A person rolls a standard six-sided die 9 times. In how many ways can he get 3 fours, 5 sixes, and 1 two?
This is the probability of rolling 3 fours, 5 sixes, and 1 two in 9 times.
factorial(9) / ( factorial(3) * factorial(5) * factorial(1))
## [1] 504
How many ways can Rudy choose 6 pizza toppings from a menu of 14 toppings if each topping can only be chosen once?
Ben: Come back to this later, combination or permutation?
\[^{14} P_6 = \frac{14!}{(14 - 6)!~6!}\]
Answer. 3003 combinations
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?
This is different from a typical combination problem because of the “without replacement” specification. We need to account for the fact that the probabilities change after each each card is drawn, i.e., account for the fact these card draws are dependent events.
In such cases, use the formula:
\[^{n} C_k = \frac{n!}{k! ~ (n - k)!}\]
n <- 52
k <- 3
c_n_k <- factorial(n) / (factorial(k) * factorial(n - k))
Note that the answer is significantly less than a “regular” combination of 132,600, which makes sense because dependence “restrains” the possible outcomes.
Answer. \(22100\) possible unique three-card hands
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?
Answer. \(12 \times 9 \times 5 =\) 540 possible home theater systems
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?
Assuming we are only dealing with lowercase letters, R has a built-in set of each 26 lowercase characters called letters.
n_letters <- length(letters)
digits <- c(1, 3, 5, 7, 9)
n_digits <- length(digits)
Since characters and digits can only be used once, this is a permutation problem:
perm_letters <- factorial(n_letters) / factorial(n_letters - 5)
perm_digits <- factorial(n_digits) / factorial(n_digits - 3)
perm_letters * perm_digits
## [1] 473616000
Answer. 473,616,000 possible passwords
Evaluate the following expression: \(^{9} P_4\).
\[^{9} P_4 = \frac{9!}{(9 - 4)!}\]
Answer. 3024
Evaluate the following expression: \(^{11} C_8\).
factorial(11) / ( factorial(11 - 8) * factorial(8) )
## [1] 165
Evaluate the following expression:
\[ \frac{^{12} P_8}{^{12} C_4}\]
num <- factorial(12) / factorial(12 - 8)
denom <- factorial(12) / ( factorial(12 - 4) * factorial(4) )
num / denom
## [1] 40320
The newly elected president needs to decide the remaining 7 spots available in the cabinet he/she is appointing. If there are 13 eligble canddiates for these positions (where rank matters), how many different ways can the members of the cabinet be appointed?
“Where rank matters” implies a permutation problem:
factorial(13) / factorial(13 - 7)
## [1] 8648640
Answer. 8,648,640 possible cabinets
In how many ways can the letters in the word ‘Population’ be arranged?
Counting the capital P as lowercase p, we need to account for the fact there are two p’s and two o’s in this counting problem in the denominator:
factorial(10) / (factorial(2) * factorial(2))
## [1] 907200
Answer. 907,200 different “words”
Consider the following data.
x <- seq(5, 9, 1)
p_x <- c(.1, .2, .3, .2, .2)
df <- data.frame(x=x, p_x=p_x)
kable(df)
| x | p_x |
|---|---|
| 5 | 0.1 |
| 6 | 0.2 |
| 7 | 0.3 |
| 8 | 0.2 |
| 9 | 0.2 |
Step 1. Find the expected value \(E(X)\). Round your answer to one decimal place.
e_x <- sum(df$x * df$p_x)
e_x
## [1] 7.2
Answer. \(E(X) = 7.2\)
Step 2. Find the variance. Round your answer to one decimal place.
Since this is a discrete variable, we have to use:
\[\sigma^2 = \sum (x - E(x))^2 ~ p_x\]
sum((df$x - e_x)^2 * df$p_x)
## [1] 1.56
Answer. \(\sigma^2_x = 1.6\)
Step 3. Find the standard deviation. Round your answer to one decimal place.
Standard deviation is the square root of variance:
sqrt(sum((df$x - e_x)^2 * df$p_x))
## [1] 1.249
Answer. 1.2
Step 4. Find the value of \(P(X \geq 9)\). Round your answer to one decimal place.
This is the sum of \(x\) where \(P(x)\) is greater than or equal to 9.
sum(df$p_x[df$x >= 9])
## [1] 0.2
Step 5. Find the value of \(P(X \leq 7)\). Round your answer to one decimal place.
Like above:
sum(df$p_x[df$x <= 7])
## [1] 0.6
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.
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
Where \(\pi_i\) is the expected payout associated with event \(i \in I\) where length of \(I\) is \(N\), expected value \(EV\) is:
\[ EV = \sum_{i=1}^N \pi_i ~ P(x_i)\]
pi_success <- 23
pi_fail <- -4
p_success <- 188 / 376 # = .5
p_fail <- 1 - p_success
ev <- (p_success^3 * pi_success) + (p_fail^3 * pi_fail)
Answer. EV = $2.38
Step 2. If you played this game 994 times how much would you expect to win or lose? (Losses must be entered as negative.)
ev * 994
## [1] 2360.75
Flip a coin 11 times. If you get 8 tails or less, I will pay you $1. Otherwise you pay me $7.
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
There are \(2^{11} = 2048\) possible outcomes. We need to find the number of outcomes where there are 8 tails or less to find the probability of success. This is the sum of combinations where \(k = 1\) tail, \(k = 2\) tails, \(\ldots\), \(k = 8\) tails.
combinatric <- function(k, n) {
factorial(n) / ( factorial(k) * factorial(n - k) )
}
K <- seq(0, 8, 1)
P <- sapply(K, combinatric, n=11)
n_8_less <- sum(P)
So there are 1981 outcomes with 8 or less tails. The probability of such an outcome is therefore 0.9672852.
Calculating the expected value:
pi_success <- 1
pi_fail <- -7
p_success <- n_8_less / (2^11)
p_fail <- 1 - p_success
ev <- (pi_success * p_success) + (pi_fail * p_fail)
Answer. \(EV =\) $0.74
Step 2. If you played this game 615 times how much would you expect to win or lose? (Losses must be entered as a negative.)
Answer. \(EV_{615} = 615 \times EV =\) 454.04 dollars
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.)
Step 1. Find the expected value of the proposition. Round your answer to decimal places.
pi_success <- 583
pi_fail <- -35
p_first_draw <- 13/52
p_second_draw <- 12/51
p_success <- p_first_draw * p_second_draw
p_fail <- 1 - p_success
ev <- (pi_success * p_success) + (pi_fail * p_fail)
Answer. \(EV =\) $1.35
Step 2. If you played this game 632 times how much would you expect to win or lose? (Losses must be entered as negative.)
Rounding only the final calcuation and no intermediate steps:
Answer. \(EV_{632} = EV \times 632 =\) $855.06
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.)
The distribution under question in binomial, where the two outcomes are pass inspection and fail inspection. This question is asking, “What are the odds of getting such an extreme sample from this distribution?”, i.e., what is the probability of a false negative, i.e., what is the area under the cumulative density function between 0 and 2?
We can use R’s pbinom() function to calculate exactly this:
pbinom(2, 10, .3)
## [1] 0.3827828
Answer. 0.38
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.
.3 * 5
## [1] 1.5
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.)
We can use R functions as above, but we need to decide how we want to model this distribution. Since this is count data, I’ll assume we want to model with Poisson distribution (but there might be reasons for using the normal):
ppois(5, 5.5, lower=FALSE)
## [1] 0.4710813
Use lower=FALSE to tell R to only pay attention to the area to the right of 5, as implied by “more than five.”
Answer. 0.4711 (if modeled as Poisson)
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.)
Since this is count data, I will again model it as Poisson, again using lower=FALSE:
ppois(4, 5.7, lower=FALSE)
## [1] 0.6727852
Answer. 0.6728 (if modeled as Poisson)
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.)
Again model as a Poisson, but with lower=TRUE this time. Multiple the daily mean by 7 to get the weekly mean of 2.8 crashes/week:
ppois(1, 2.8, lower=TRUE)
## [1] 0.2310782
Answer. 0.2311 (if modeled as Poisson)
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.
At first glance this appears to refer to a binomial distribution, except for “success”—getting dismissed—are not independent events. This means we’re dealing with a hypergeometric distribution.
We can use the R function pyhyper() to determine the area underneath the cumulative density function between 1 and 6 (the number of senior employees):
x <- 1 # minimum number of seniors dismissed
m <- 6 # number of seniors
n <- 19 # number of youths
k <- 8 # number dismissed
phyper(x, m, n, k, lower=FALSE)
## [1] 0.6505929
Answer. 0.651
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.
This is again a hypergeometric distribution, but where lower=TRUE:
x <- 7 # maximum of deaths we're interested in
m <- 10 # number of people w/fatal heart problem
n <- 15 # number of people w/o fatal heart problem
k <- 8 # Number selected to receive the drug
phyper(x, m, n, k, lower=TRUE)
## [1] 0.9999584
Answer. 1