<- (0.60 * 0.70) / ((0.60 * 0.70) + (0.10 * 0.30))
p_found_locator
<- 1 - p_found_locator
p_not_found_loc round(p_not_found_loc,3)
Course 1 prep
Week 1
Module 1 Quiz
Problem 1:
For each of the following scenarios, find the requested probability. Assume the sets \(A\), \(B\), and \(C\) are events from the same sample space \(S\). (Hint: Venn diagrams may help with the visualization, although they are not required to answer the questions.)
Given the following probabilities: - \(P(A) = 0.4\) - \(P(B^c) = 0.7\) - \(P(A \cap B^c) = 0.2\)
Find \(P(A \cap B)\).
Answer
0.2
The entire A circle is 0.4, the entire A circle minus the overlapping section is 0.2, meaning the leftover A section is 0.2
\(P(A) - P(A \cap B^c) = P(A \cap B) = 0.4 - 0.2 = 0.2\)
Problem 2:
For each of the following scenarios, find the requested probability. Assume the sets \(A\), \(B\), and \(C\) are events from the same sample space \(S\). (Hint: Venn diagrams may help with the visualization, although they are not required to answer the questions.)
Given the following probabilities: - \(P(A) = 0.9\) - \(P(B) = 0.9\)
What is the lower bound for \(P(A \cup B)\)?
Answer
0.9
This is just the likelihood of either complete circle, so the lower bound will always be the lowest individual probability when phrased this way.
Problem 3:
Three popular options on a certain type of car are \(A\) (leather seats), \(B\) (a sunroof), and \(C\) (heated seats). In the past:
- \(P(A) = 0.55\) (i.e., 55% of the customers have requested option A),
- \(P(B) = 0.45\),
- \(P(C) = 0.4\).
Furthermore: - \(P(A \cap B) = 0.25\), - \(P(A \cap C) = 0.2\), - \(P(B \cap C) = 0.15\), - \(P(A \cap B \cap C) = 0.1\).
Find the probability that a customer will ask for at least one of the three options.
Answer
0.9
This is the total of each individual circle, minus each overlapping section of two circles, and then re-adding in the center overlap of all three because it is getting subtracted out 3 times when it only needs to be subtracted out twice.
\(P(at least one) = P(A) + P(B) + P(C) - P(A \cap B) - (A \cap C) - (B \cap C) + P(A \cap B \cap C)\)
\(0.55 + 0.45 + 0.4 - 0.25 - 0.20 - 0.15 + 0.1\)
Problem 4:
Three popular options on a certain type of car are \(A\) (leather seats), \(B\) (a sunroof), and \(C\) (heated seats). In the past:
- \(P(A) = 0.55\) (i.e., 55% of the customers have requested option A),
- \(P(B) = 0.45\),
- \(P(C) = 0.4\).
Furthermore: - \(P(A \cap B) = 0.25\), - \(P(A \cap C) = 0.2\), - \(P(B \cap C) = 0.15\), - \(P(A \cap B \cap C) = 0.1\).
Find the probability that a customer will not ask for any of these three options.
Answer
0.1
This is just the complement of the above answer (the alternative to asking for at least one of something is to ask for nothing.)
Problem 5:
Three popular options on a certain type of car are \(A\) (leather seats), \(B\) (a sunroof), and \(C\) (heated seats). In the past:
- \(P(A) = 0.55\) (i.e., 55% of the customers have requested option A),
- \(P(B) = 0.45\),
- \(P(C) = 0.4\).
Furthermore: - \(P(A \cap B) = 0.25\), - \(P(A \cap C) = 0.2\), - \(P(B \cap C) = 0.15\), - \(P(A \cap B \cap C) = 0.1\).
Find the probability that a customer will ask for heated leather seats but not a sunroof.
Answer
0.1
Heated Leather seats is \(P(A \cap C) = 0.2\) and inluding a sunroof is \(P(A \cap B \cap C) = 0.1\) so removing the sunroof probability is
\(P(A \cap B) - P(A \cap B \cap C) = 0.2 - 0.1 = 0.1\)
Problem 6:
Three popular options on a certain type of car are \(A\) (leather seats), \(B\) (a sunroof), and \(C\) (heated seats). In the past:
- \(P(A) = 0.55\) (i.e., 55% of the customers have requested option A),
- \(P(B) = 0.45\),
- \(P(C) = 0.4\).
Furthermore: - \(P(A \cap B) = 0.25\), - \(P(A \cap C) = 0.2\), - \(P(B \cap C) = 0.15\), - \(P(A \cap B \cap C) = 0.1\).
Find the probability that a customer will ask for at most two of the options.
Answer
0.9
This is the probability of everything but asking for all 3 options (don’t forget that asking for none of them counts in this case, “at most 2, inluding 0.)
So it’s just \(1 - P(A \cap B \cap C) = 0.9\)
Problem 7:
Three popular options on a certain type of car are \(A\) (leather seats), \(B\) (a sunroof), and \(C\) (heated seats). In the past:
- \(P(A) = 0.55\) (i.e., 55% of the customers have requested option A),
- \(P(B) = 0.45\),
- \(P(C) = 0.4\).
Furthermore: - \(P(A \cap B) = 0.25\), - \(P(A \cap C) = 0.2\), - \(P(B \cap C) = 0.15\), - \(P(A \cap B \cap C) = 0.1\).
Find the probability that a customer will ask for exactly two of the options.
Answer
0.3
This is just the total of all of the double overlaps minuse the triple overlap, so it can be subracted from each before adding or subtracted 3 times on it’s own (for each overcounting.)
\(P(A \cap B) + P(A \cap C) + P(B \cap C) - 3 \cdot P(A \cap B \cap C)\)
\((P(A \cap B) - P(A \cap B \cap C)) + (P(A \cap C) - P(A \cap B \cap C)) + (P(B \cap C) - P(A \cap B \cap C))\)
\(0.25 + 0.2 + 0.15 - (3 * 0.1) = 0.3\)
Problem 8:
A message of length 5 digits is to be sent. Each digit can be a 0, 1, or 2.
What is the cardinality of the sample space?
Answer
243
Just the number of possible options
\(3^5 = 243\)
Problem 9:
A message of length 5 digits is to be sent. Each digit can be a 0, 1, or 2.
If every message is equally likely, what is the probability that the message consists of 2 zeros, 2 ones, and 1 two? Round your answer to four decimal places.
Answer
0.1235
A single two can assume 5 different positions. The number of ways that the two remaining digits can occupy four spaces is \(\binom{4}{2} = 6\) so the overall probability is
\[\frac {5 \cdot \binom{4}{2}}{3^5} = \frac{30}{243} \approx 0.1235\]
Problem 10:
A message of length 5 digits is to be sent. Each digit can be a 0, 1, or 2.
What is the probability that the message contains at least one zero? Round your answer to three decimal places.
Answer
0.868
Direct calculation: All possibilities is \(3^5 = 243\) and all possibilities using only ones and twos is \(2^5 = 32\) so the total minus the non-zeroes options is
\[\frac {3^5 - 2^5}{3^5} = \frac {243 - 32}{243} \approx 0.869\]
Complement approach:
\(P(\text{no zeros}) = \frac{2^5}{3^5} = \frac{32}{243}\)
\(P(\text{at least one zero}) = 1 - P(\text{no zeros}) = 1 - \frac{32}{243} = \frac{243 - 32}{243} = \frac{211}{243}\)
Week 2
Module 2 Quiz
Question 1:
For each of the following scenarios, answer the question with a numerical answer or a “Yes” or “No”. If you do not have enough information, write “Can’t tell”. For all situations, assume \(0 < P(A) < 1\) and \(0 < P(B) < 1\).
If \(A\) and \(B\) are two events such that: - \(P(A) = 0.7\), - \(P(B) = 0.5\), - \(P(B \mid A) = 0.6\),
Find \(P(A \cup B)\). If possible, round your answer to two decimal places.
Answer
0.78
Question 2:
For each of the following scenarios, answer the question with a numerical answer or a “Yes” or “No”. If you do not have enough information, write “Can’t tell”. For all situations, assume \(0 < P(A) < 1\) and \(0 < P(B) < 1\).
If \(A\) is a subset of \(B\), can \(A\) and \(B\) be independent? (Answer Yes, No, or Can’t tell.)
Answer
No
Question 3:
For each of the following scenarios, answer the question with a numerical answer or a “Yes” or “No”. If you do not have enough information, write “Can’t tell”. For all situations, assume \(0 < P(A) < 1\) and \(0 < P(B) < 1\).
If \(A\) is a subset of \(B\), calculate \(P(B \mid A)\), if you can. (If you can’t, answer Can’t tell.)
Answer
1
Question 4:
For each of the following scenarios, answer the question with a numerical answer or a “Yes” or “No”. If you do not have enough information, write “Can’t tell”. For all situations, assume \(0 < P(A) < 1\) and \(0 < P(B) < 1\).
If \(A\) is a subset of \(B\), calculate \(P(A \mid B)\), if you can. (If you can’t, answer Can’t tell.)
Answer
Can’t tell
Question 5:
For each of the following scenarios, answer the question with a numerical answer or a “Yes” or “No”. If you do not have enough information, write “Can’t tell”. For all situations, assume \(0 < P(A) < 1\) and \(0 < P(B) < 1\).
If \(P(A) = 0.8\), \(P(B \mid A) = 0.5\), and \(A\) and \(B\) are dependent (not independent), then is \(P(B) \leq P(A)\)? (Answer Yes, No, or Can’t tell.)
Answer
Can’t Tell (too many missing variable)
Question 6:
An unfair coin is flipped four times. The probability of heads is \(0.6\) and the probability of tails is \(0.4\). Every flip is independent of every other flip.
Find the probability of getting exactly 2 heads and 2 tails. Round your answer to four decimal places.
Answer
0.3456
Probability of that outcome
\[0.6 \times 0.6 \times 0.4 \times 0.4 = 0.0576\]
then multiply that by the number of ways to arrange that result
\[\binom {4}{2} = 6\]
\[((0.6)^2 \times (0.4)^2) \times \binom{4}{2} \approx 0.3456\]
or
round(((0.6 * 0.6 * 0.4 * 0.4) * 6),4)
Question 7:
An unfair coin is flipped four times. The probability of heads is \(0.6\) and the probability of tails is \(0.4\). Every flip is independent of every other flip.
Find the probability of getting exactly 2 heads and 2 tails given that the first coin flip was a head. Round your answer to three decimal places.
Answer
0.288
The same as the previous with different numbers
Probability of that outcome
\[0.6 \times 0.4 \times 0.4\]
then multiply that by the number of ways to arrange that result
\[\binom {3}{2} = 3\]
\[((0.6) \times (0.4)^2) \times \binom{3}{2} \approx 0.288\]
or
<- 0.6 * 0.4 * 0.4
p <- choose(3,2)
arrange <- p * arrange
total
p
arrange total
Question 8:
\(70\%\) of the light aircraft that disappear while in flight in a certain country are subsequently found. Of the aircraft that are found, \(60\%\) have an emergency locator, whereas only \(10\%\) of the aircraft not found have such a locator. Suppose a light aircraft has disappeared.
If the aircraft has an emergency locator, what is the probability that it will not be found? Round your answer to three decimal places.
Answer
0.067
Question 9:
\(70\%\) of the light aircraft that disappear while in flight in a certain country are subsequently found. Of the aircraft that are found, \(60\%\) have an emergency locator, whereas only \(10\%\) of the aircraft not found have such a locator. Suppose a light aircraft has disappeared.
Are the two events $L = $ the plane has a locator and $F = $ the plane is found independent? (Answer Yes or No.)
Answer
No
Week 3
Module 3 Quiz
Question 1:
A critical system has 5 different components, each of which works with probability 0.90. Assume each component works independently of the others. Let \(X\) be the number of components that are working.
Find \(P(X=2)\). Round your answer to four decimal places.
Answer
0.0081
round(dbinom(2, 5, 0.90),4)
The probably of the number of sucesses is \(p^k = 0.90^2\) the probability of the number of failures is \((1-p)^{n-k} = (1-0.90)^{5-2}\) and the ways to arrange those is \({n \choose k} = {5 \choose 2}\) which give the entire pdf
\[ P(X=x) = {n \choose k}p^k (1-p)^{n - k}\]
Question 2:
A critical system has 5 different components, each of which works with probability 0.90. Assume each component works independently of the others. Let \(X\) be the number of components that are working.
Find \(E(X)\).
Answer
4.5
This one can be worked out logically. For binomial \(E[X] = np\)Question 3:
A critical system has 5 different components, each of which works with probability 0.90. Assume each component works independently of the others. Let \(X\) be the number of components that are working.
Find \(V(X)\). Round your answer to two decimal places.
Answer
0.45
For Binomial \(Var[X] = np(1-p)\) and will just come from the sheet.Question 4:
A certain type of item produced by a factory has a 6% chance of being defective. Draw a random sample until you get the first defective. Let \(X\) be the number of items that are drawn.
Find \(P(X=2)\). Round your answer to four decimal places.
Answer
0.0564
This is the first success variation on a geometrics distribution \[P(X=x) = (1-p)^{x-1}p\]
\[P(X=2) = (1-0.06)^{2-1}\times 0.06 = 0.0564\]
The only difference from the standard Geometric is subtracting 1 from the \(x\) in the exponent and adding 1 to calculate \(E[X]\)<- 2
x <- 0.06
p
1-p)^(x-1) * p (
Question 5:
A certain type of item produced by a factory has a 6% chance of being defective. Draw a random sample until you get the first defective. Let \(X\) be the number of items that are drawn.
Find \(E(X)\). Round your answer to two decimal places.
Answer
16.67
\(E[X]\) for the Geometric distribution is \(\frac {1}{p} - 1\), for the first sucess variation you just have to add one to account for the additional count of including the success \[\frac{1}{p}\].Question 6:
A certain type of item produced by a factory has a 6% chance of being defective. Draw a random sample until you get the first defective. Let \(X\) be the number of items that are drawn.
Find \(V(X)\). Round your answer to two decimal places.
Answer
261.11
The variance of the first success Geometric and standard Geometric will be the same, since inluding the success just shifts the distribution, but doesn’t change the spread.
\[\frac{1-p}{p^2} = \frac{1-0.06}{0.06^2} = 261.11\]1-p) / p^2 (
Question 7:
A certain system can experience three different types of defects. Let \(A_i\), \(i = 1, 2, 3\) be the event that the system has a defect of type \(i\). Suppose that: - \(P(A_1) = 0.17\) - \(P(A_2) = 0.07\) - \(P(A_3) = 0.13\) - \(P(A_1 \cup A_2) = 0.18\) - \(P(A_2 \cup A_3) = 0.18\) - \(P(A_1 \cup A_3) = 0.19\) - \(P(A_1 \cap A_2 \cap A_3) = 0.01\)
Let the random variable \(X\) be the number of defects that are present.
Calculate \(P(X=0)\).
Answer
0.81
Add together all of the single occurrence probabilities, subtract all of the two-occurrence probabilities because they all got counted twice, then add back in the three-occurence probability because it got added in three times and then subtracted three times but needs to be counted once. Then subtract that from 1 to get the probability of no occurrence. (Draw a picture.)
\[1 - P(A_1) + P(A_2) + P(A_3) - P(A_1 \cup A_2) - P(A_2 \cup A_3) - P(A_1 \cup A_3) + P(A_1 \cap A_2 \cap A_3)\]<- 0.17
one <- 0.07
two <- 0.13
three <- 0.18
one_or_two <- 0.18
two_or_three <- 0.19
one_or_three <- 0.01
one_two_threes
<- one + two - one_or_two
one_and_two <- two + three - two_or_three
two_and_three <- one + three - one_or_three
one_and_three
<- one + two + three - one_and_two - one_and_three - two_and_three + (1 * one_two_threes)
total
1-total
Question 8:
A certain system can experience three different types of defects. Let \(A_i\), \(i = 1, 2, 3\) be the event that the system has a defect of type \(i\). Given the same information as Question 7, calculate \(P(X=1)\).
Answer
0.02
Take the total probability of any type of defect occurring from the previous quesion (0.19) and subtract all the two-defect probabilities, then re-add the three-defect option twice because it got subtracted too many times.
\[P(X=1) = P(X>0) - P(A_1 \cap A_2) - P(A_2 \cap A_3) - P(A_1 \cap A_3) + (2 \times P(A_1 \cap A_2 \cap A_3))\]
or
round(
- one_and_two - one_and_three - two_and_three + (2 * one_two_threes),
total 3
)
Question 9:
A certain system can experience three different types of defects. Let \(A_i\), \(i = 1, 2, 3\) be the event that the system has a defect of type \(i\). Given the same information as Question 7, calculate \(P(X=2)\).
Answer
0.16
Similar to before, but just add together all the two-defect possibilities, then subtract the three-defect option three times because it got added in each time. NOTE THAT THE TWO-DEFECT PROBABILITIES ARE NOT GIVEN AND MUST BE CALCULATED (cups to caps)
\[P(X=2) = P(A_1 \cap A_2) + P(A_2 \cap A_3) + P(A_1 \cap A_3) - (3 \times P(A_1 \cap A_2 \cap A_3))\]
\[P(X=2) = 0.06 + 0.02 + 0.11 - 3(0.01) = 0.16\]
+ one_and_three + two_and_three - (3 * one_two_threes) one_and_two
Question 10:
A certain system can experience three different types of defects. Let \(A_i\), \(i = 1, 2, 3\) be the event that the system has a defect of type \(i\). Given the same information as Question 7, calculate \(P(X=3)\).
Answer
0.01
This is just the overlapping of all three circles.
\[P(X=3) = P(A_1 \cap A_2 \cap A_3) = 0.01\]Question 11:
A certain system can experience three different types of defects. Let \(A_i\), \(i = 1, 2, 3\) be the event that the system has a defect of type \(i\). Given the same information as Question 7, find \(E(X)\).
Answer
0.37
This is the probability weight average of each outcome value \[P(X=0) = 0.81\] \[P(X=1) = 0.02\] \[P(X=2) = 0.16\] \[P(X=3) = 0.01\]
\[E[X] = 0\times(0.81) + 1\times(0.02) + 2\times(0.16) + 3\times(0.01) = 0.37\]0 * 0.81) + (1 * 0.02) + (2 * 0.16) + (3 * 0.01)) ((
Question 12:
A certain system can experience three different types of defects. Let \(A_i\), \(i = 1, 2, 3\) be the event that the system has a defect of type \(i\). Given the same information as Question 7, find \(V(X)\). Round your answer to four decimal places.
Answer
0.6131
\[Var[X] = E[X^2] - E[X]^2\]
\[0^2 \times(0.81) + 1^2 \times(0.02) + 2^2\times(0.16) + 3^2\times(0.01) - (0.37)^2\]
<- c(0.81, 0.02, 0.16, 0.01)
probs <- c(0, 1, 2, 3)
vals
<- sum(vals^2 * probs)
exp_x_squared <- 0.37
exp_x
- exp_x^2 exp_x_squared
Question 13:
A certain system can experience three different types of defects. Let \(A_i\), \(i = 1, 2, 3\) be the event that the system has a defect of type \(i\). Given the same information as Question 7, find \(\sigma\), the standard deviation of \(X\). Round your answer to three decimal places.
Answer
0.783
\[\sigma = \sqrt{(Var[X])} = \sqrt{0.6131} = 0.7830\]sqrt(0.6131)
Week 4
Module 4 Quiz
Question 1:
A skilled worker requires at least 10 minutes, and no more than 20 minutes, to complete a certain task. The completion time \(X\) is a continuous random variable with density function:
\[ f(x) = \frac{c}{x^2} \text{ for } 10 \leq x \leq 20 \] and \[ f(x) = 0 \text{ for all other values of } x. \]
What is the value of \(c\)?
Answer
20
The integral over that range must equal one since it is a complete probability.
\[\int_{10}^{20}\frac{c}{x^2}\,dx = c\int_{10}^{20}x^{-2}\,dx = 1\]
\[c \cdot[-\frac{1}{x}] \big|_{10}^{20} = c\cdot \frac{1}{20} = 1\]
\[c = 20\]
or
<- function(x) {
f 1/(x^2)
}
integrate(f, 10, 20)
Question 2:
A skilled worker requires at least 10 minutes, and no more than 20 minutes, to complete a certain task. The completion time \(X\) is a continuous random variable with density function:
\[ f(x) = \frac{c}{x^2} \text{ for } 10 \leq x \leq 20 \] and \[ f(x) = 0 \text{ for all other values of } x. \]
Find the probability that the worker completes the task in 15 minutes or less. Round your answer to three decimal places.
Answer
0.667
Now we know the actual function we can integrate over any range of interest.
\[\int_{10}^{15}\frac{20}{x^2}\,dx = \frac{2}{3} \approx 0.667\]
<- function (x) {
f 20 / x^2
}
integrate(f, 10, 15)
<- function (x) {
f 20 / x^2
}
integrate(f, 10, 15)
0.6666667 with absolute error < 7.4e-15
Question 3:
A skilled worker requires at least 10 minutes, and no more than 20 minutes, to complete a certain task. The completion time \(X\) is a continuous random variable with density function:
\[ f(x) = \frac{c}{x^2} \text{ for } 10 \leq x \leq 20 \] and \[ f(x) = 0 \text{ for all other values of } x. \]
Find the expected time for the worker to complete the task. Round your answer to three decimal places.
Answer
13.863
The expectation formula is the integral of the distribution function multiplied by \(x\) over the relevant domain.
\[E[X] = \int_{a}^{b} x \cdot f(x)\,dx\]
\[E[X] = \int_{10}^{20} x \cdot \frac{20}{x^2}\,dx\]
\[E[X] = \int_{10}^{20} \frac{20}{x}\,dx\]
\[E[X] = 20 \cdot \int_{10}^{20} \frac{1}{x}\,dx\]
\[E[X] = 20 \cdot (\ln{20} - \ln{10}) \approx 13.863\]
or
# if you have the integral basically solved
log(20) - log(10)) * 20
(
# whole thing
<- function(x) {
f * (20/x^2)
x
}
integrate(f, 10, 20)
log(20) - log(10)) * 20
(
<- function(x) {
f * (20/x^2)
x
}
integrate(f, 10, 20)
13.86294 with absolute error < 1.5e-13
Question 4:
The number of eggs laid on a tree leaf by an insect of a certain type is a Poisson random variable, \(X\), with parameter \(c\), where \(E(X) = c\). However, such a random variable can only be observed if it is positive, since if it is 0, then we cannot know that such an insect was on the leaf. If we let \(Y\) denote the observed number of eggs, then:
\[ P(Y = i) = P(X = i \mid X > 0) \]
where \(X\) is Poisson with parameter \(c\).
Find \(E(Y)\).
(Note 1: your answer will be a mathematical expression with \(c\). When you type in your answer, the preview box will display what the mathematical expression looks like.)
Answer
WTF probably just skip this one
The Poisson PDF is \(P(X = k) = \frac{\lambda^k e^{-\lambda}}{k!}, \quad k = 0, 1, 2, \ldots\)
or in this case
\[P(X = i) = \frac{c^i e^{-c}}{i!}, \quad i = 0, 1, 2, \ldots\]
We have to offset everything to exclude the 0 option. \[P(Y = i) = P(X = i \mid X > 0)\]
is a conditional probability, so we can use the conditional probability equation to get
\[P(Y = i) = \frac{P(X = i)}{P(X > 0)} = \frac{\frac{e^{-c} c^i}{i!}}{1 - e^{-c}}\]
Note: The bottom term comes from
\[P(X=0) = e^{-c}\]
so the probability that \(PX(>0)\) is the complement
\[1 - e^{-c}\]
End Note.
\[\frac{\frac{e^{-c} c^i}{i!}}{1 - e^{-c}}\]
Then we calculate the expectation
\[E(Y) = \frac{1}{1 - e^{-c}} \sum_{i=1}^\infty \frac{i c^i}{i!}\]
Simplify the series: The term \[\sum_{i=1}^\infty \frac{i c^i}{i!}\]
can be rewritten as:
\[\sum_{i=1}^\infty \frac{i c^i}{i!} = c \sum_{i=1}^\infty \frac{c^{i-1}}{(i-1)!} = c \cdot \sum_{k=0}^\infty \frac{c^k}{k!} = c \cdot e^c\]
So:
\[E(Y) = \frac{1}{1 - e^{-c}} \cdot c\]
Simplify the expression:
\[E(Y) = \frac{c}{1 - e^{-c}}\]
Question 5:
Suppose \(X\) is a random variable \(X \sim N(12, 4)\).
Find the probability that \(X\) is within 1.5 standard deviations of the mean. Round your answer to four decimal places.
Answer
0.8664
\[ P(9 \leq X \leq 15) = P(-1.5 \leq Z \leq 1.5) = \Phi(1.5) - \Phi(-1.5) \approx 0.9332 - 0.0668 = 0.8664 \]
The variance is 4, so so the standard deviation is 2, so 1.5 SD is 3 in each direction around the mean, giving a range of 9-15. From there it’s just pnorm lookups. (Don’t forget that pnorm() asks for SD but notation give variance.)
# quick
pnorm(15, 12, 2) - pnorm(9, 12, 2)
# or long form
<- 12
mean <- 4
var <- sqrt(var)
sd
pnorm(mean + (1.5 * sd), mean, var) - pnorm(mean - (1.5 * sd), mean, var)
Question 6:
Suppose \(X\) is a random variable \(X \sim N(12, 4)\).
Find \(k\) such that \(P(X > k) = 0.10\). Round your answer to two decimal places.
Answer
14.56
Just a cdf lookup (qnorm()). Don’t forget the direction - this is asking for 10% over, qnorm() looks up the value cumulative probability under, so need to do 1-prob in this case.
<- 12
mean <- 4
var <- sqrt(var)
sd
<- qnorm(0.90, mean, sd) cutoff
<- 12
mean <- 4
variance <- sqrt(variance)
sd
<- qnorm(0.90, mean, sd)
cutoff
round(cutoff,2)
Week 5
Module 5 Quiz
Question 1:
A store orders 10 units of a certain item. For each unit sold, it makes $10. For each item that remains unsold, it loses $5. Let \(X\) be the number of items sold in a week. If the store knows that \(X\) is a discrete uniform random variable, with \(X\) taking values \(\{0,1,\dots,10\}\), find the expected profit.
Answer
25
The intuitive approach is to combine the average gain and the average loss. Since these are simple distributions the expected gain over all outcomes is $50 and the expected loss is -$25, so the overall expected gain is $25.
This only works because they are linear operators.<- 100 / 2
gain <- 50 / 2
loss
- loss gain
Question 2:
Suppose that the service time at a call center is exponentially distributed with the average call lasting 10 minutes. If 3 workers are each on a call, what is the probability that they have each completed their service in 12 minutes? Assume that the length of each call is independent of every other call. Round your answer to four decimal places.
Answer
0.3412
Since the average time is 10 minutes then the rate \(\lambda\) is 1 every 10 minutes \(\lambda = 1/10\)
The probability that an individual worker finishes in under 12 minutes can be calculated from the PDF
\[P(X\leq x) = 1 - e^{-\lambda x}\]
\[P(X\leq 12) = 1-e^{-\frac{1}{10} \cdot 12} \approx 0.6988\]
or with pexp()
<- 1/10
lambda
pexp(12, lambda)
Then since each worker is independent the probability that all of them finish in under 12 minutes is just each probability multiplied together, \((P \leq 12)^3 \approx 0.3412\)
1 - exp(-(1/10) * 12)
<- pexp(12,1/10)
single_worker
single_worker
round((single_worker^3),4)
Question 3:
Suppose that \(X\) and \(Y\) are random variables with the joint probability mass function given by the table below.
- | \(y=1\) | \(y=4\) | \(y=16\) |
---|---|---|---|
\(x=1\) | 0.20 | 0.25 | 0.05 |
\(x=5\) | 0.10 | 0.15 | 0.25 |
Find \(P(X = 1)\).
Answer
0.5
Add up all the marginal probabilities for which \(x=1\).
\[0.20 + 0.25 + 0.05 = 0.50\]Question 4:
Suppose that \(X\) and \(Y\) are random variables with the joint probability mass function given by the table below.
— | \(y=1\) | \(y=4\) | \(y=16\) |
---|---|---|---|
\(x=1\) | 0.20 | 0.25 | 0.05 |
\(x=5\) | 0.10 | 0.15 | 0.25 |
Find \(P(X > Y)\).
Answer
0.25
Just add up marginal probabilities.
— | \(y=1\) | \(y=4\) | \(y=16\) |
---|---|---|---|
\(x=1\) | 0.20 | 0.25 | 0.05 |
\(x=5\) | 0.10 | 0.15 | 0.25 |
Question 5:
Suppose that \(X\) and \(Y\) are random variables with the joint probability mass function given by the table below.
- | \(y=1\) | \(y=4\) | \(y=16\) |
---|---|---|---|
\(x=1\) | 0.20 | 0.25 | 0.05 |
\(x=5\) | 0.10 | 0.15 | 0.25 |
Determine \(Cov(X, Y)\).
Answer
5.4
\[Cov(X,Y) = E\Big(\big(X-E(X)\big)\big(Y - E(Y)\big)\Big)\]
which simplifies to
\[Cov(X,Y) = E[XY] - E[X] \cdot E[Y]\]
by hand this looks like
\[ E[X] = (1)(0.50) + (5)(0.50) = 3\] \[ E[Y] = (1)(0.30) + (4)(0.40) + (16)(0.30) = 6.7\] \[ \begin{align*} E[XY] = & \, (1)(1)(0.20) + (1)(4)(0.25) + (1)(16)(0.05) + \\ & \, (5)(1)(0.10) + (5)(4)(0.15) + (5)(16)(0.25) = 25.5 \end{align*}\]
\[Cov(X,Y) = 25.5 - (3 \cdot 6.7) = 5.4\]
Programmatically
<- c(1, 5)
x <- c(1, 4, 16)
y
<- c(0.5, 0.5)
x_prob <- c(0.30, 0.40, 0.30)
y_prob
<- sum(x * x_prob)
exp_x <- sum(y * y_prob)
exp_y
# this part is tricky, might have to do it by hand instead
<- matrix(c(0.20, 0.25, 0.05,
prob_matrix 0.10, 0.15, 0.25),
nrow = 2, byrow = TRUE)
<- sum(outer(x, y, "*") * prob_matrix)
exp_x_y
<- exp_x_y - (exp_x * exp_y)
covariance_x_y #5.4 covariance_x_y
<- c(1, 5)
x <- c(1, 4, 16)
y
<- c(0.5, 0.5)
x_prob <- c(0.30, 0.40, 0.30)
y_prob
<- matrix(c(0.20, 0.25, 0.05,
prob_matrix 0.10, 0.15, 0.25),
nrow = 2, byrow = TRUE)
<- sum(x * x_prob)
exp_x <- sum(y * y_prob)
exp_y <- sum(outer(x, y, "*") * prob_matrix)
exp_x_y
<- (sum(x^2 * x_prob)) - exp_x^2
var_x <- (sum(y^2 * y_prob)) - exp_y^2
var_y
<- sqrt(var_x)
sd_x <- sqrt(var_y)
sd_y
exp_x
exp_y
exp_x_y
<- exp_x_y - (exp_x * exp_y)
covariance_x_y
covariance_x_y
Question 6:
Suppose that \(X\) and \(Y\) are random variables with the joint probability mass function given by the table below.
- | \(y=1\) | \(y=4\) | \(y=16\) |
---|---|---|---|
\(x=1\) | 0.20 | 0.25 | 0.05 |
\(x=5\) | 0.10 | 0.15 | 0.25 |
Find \(\rho\), the correlation coefficient of \(X\) and \(Y\). Round your answer to four decimal places.
Answer
0.4345
\[\rho = Corr(X,Y) = \frac{Cov(X,Y)}{\sigma(x)\sigma(y)}\]
We already have \(Cov(X,Y)\) so we just have to calculate the variance of \(X\) and \(Y\).
\[Var(X) = E[X^2] - (E[X])^2\]
\[Var(X) = ((1^2)(0.50) + (5^2)(0.50)) - 3^2 = 4\]
\[Var(Y) = ((1^2)(0.30) + (4^2)(0.40) + (16^2)(0.30)) - 6.7^2 = 38.61\]
\[Corr(X,Y) = \frac {5.4}{\sqrt{4} \cdot \sqrt{38.61}} \approx 0.4345\]
<- c(1, 5)
x <- c(1, 4, 16)
y
<- c(0.5, 0.5)
x_prob <- c(0.30, 0.40, 0.30)
y_prob
<- sum(x * x_prob)
exp_x <- sum(y * y_prob)
exp_y
<- (sum(x^2 * x_prob)) - exp_x^2
var_x <- (sum(y^2 * y_prob)) - exp_y^2
var_y
<- exp_x_y - (exp_x * exp_y)
covariance_x_y
<- covariance_x_y / (sqrt(var_x) * sqrt(var_y)) corr_x_y
<- c(1, 5)
x <- c(1, 4, 16)
y
<- c(0.5, 0.5)
x_prob <- c(0.30, 0.40, 0.30)
y_prob
<- sum(x * x_prob)
exp_x <- sum(y * y_prob)
exp_y
<- (sum(x^2 * x_prob)) - exp_x^2
var_x <- (sum(y^2 * y_prob)) - exp_y^2
var_y
<- exp_x_y - (exp_x * exp_y)
covariance_x_y
<- covariance_x_y / (sqrt(var_x) * sqrt(var_y)) corr_x_y
Question 7:
Suppose that \(X\) and \(Y\) are random variables with the joint probability mass function given by the table below.
- | \(y=1\) | \(y=4\) | \(y=16\) |
---|---|---|---|
\(x=1\) | 0.20 | 0.25 | 0.05 |
\(x=5\) | 0.10 | 0.15 | 0.25 |
Are \(X\) and \(Y\) independent? (Answer “Yes”, “No”, or “Can’t determine”)
Answer
No
Using a table like above the independence of X and Y can be check by if the total probability of a given X value times the total probability of a give Y value (the marginal probabilities) equal the probability where those to X and Y meet. This must be true for every cell.
\[ P(Y=4) = 0.40 \\ P(X=5) = 0.50 \\ P(Y=4,X=5) = 0.15 \\ P(Y=4) \cdot P(X=5) = 0.20 \\ 0.15 \neq 0.20 \]Week 6
Module 6 Quiz
Question 1:
Suppose 30 numbers are selected at random from the interval \([0, 1]\). That is, \(X_i \sim U[0, 1]\) for \(i = 1, 2, \dots, 30\). Given
\[ \overline{X} = \frac{1}{30} \sum_{i=1}^{30} X_i \]
estimate \(P(0.5 \leq \overline{X} \leq 0.6)\). Round your answer to three decimal places.
Answer
0.471<- 0
a <- 1
b <- 30
n
<- (a + b) / 2
exp_this
exp_this
<- (b - a)^2 / 12
var_this
<- var_this / n
sample_var
<- sqrt(sample_var)
sem
pnorm(0.60, exp_this, sem) -
pnorm(0.50, exp_this, sem)
Question 2:
A company wants to compare the efficiency of two types of fuel for a car. 5 identical cars will be driven 500 kilometers each, two with the first type of fuel and three with the second type. Let \(X_1\) and \(X_2\) be the observed fuel efficiency for the first type and \(Y_1\), \(Y_2\), and \(Y_3\) be the efficiency for the second type. Suppose these variables are independent and:
- \(X_i \sim N(20, 4)\) for \(i = 1, 2\)
- \(Y_j \sim N(18, 9)\) for \(j = 1, 2, 3\)
Define a new random variable:
\[ W = \frac{X_1 + X_2}{2} - \frac{Y_1 + Y_2 + Y_3}{3} \]
Find \(E(W)\).
Answer
2
Expectation is a linear operator so in in this case where sample are only being added, subtracted, and multiplied by constants the expectation/mean can be plugged in.
\[E[W] = \frac{E[X] + E[X]}{2} - \frac{E[Y] + E[Y] + E[Y]}{3}\]
\[E[W] = \frac{1}{2}(E[X] + E[X]) - \frac{1}{3}(E[Y] + E[Y] + E[Y])\]
\[E[W] = \frac{1}{2}(20 + 20) - \frac{1}{3}(18 + 18 + 18) = 2\]
Question 3:
A company wants to compare the efficiency of two types of fuel for a car. 5 identical cars will be driven 500 kilometers each, two with the first type of fuel and three with the second type. Let \(X_1\) and \(X_2\) be the observed fuel efficiency for the first type and \(Y_1\), \(Y_2\), and \(Y_3\) be the efficiency for the second type. Suppose these variables are independent and:
- \(X_i \sim N(20, 4)\) for \(i = 1, 2\)
- \(Y_j \sim N(18, 9)\) for \(j = 1, 2, 3\)
Define a new random variable:
\[ W = \frac{X_1 + X_2}{2} - \frac{Y_1 + Y_2 + Y_3}{3} \]
Find \(Var(W)\).
Answer
5
Variances don’t subtract, they only addand variance is not a linear operator, so we have to do the following.
\[Var(X - Y) = Var(X) + Var(Y) - 2 \cdot Cov(X,Y)\] in this case \(X\) and \(Y\) are independent so \(Cov(X,Y) = 0\)
\[Var(X - Y) = Var(X) + Var(Y)\]
and to account for the constant terms
\[Var(aZ) = a^2Var(Z)\]
Plugging it all in
\[W = \frac{X + X}{2} - \frac{Y + Y + Y}{3}\]
\[W = \frac{1}{2}(X + X) - \frac{1}{3}(Y + Y + Y)\]
\[ Var[W] = \left(\frac{1}{2}\right)^2 (Var[X] + Var[X]) \underbrace{+}_{\text{change to +}} \left(\frac{1}{3}\right)^2 (Var[Y] + Var[Y] + Var[Y]) \]
\[Var[W] = \frac{1}{4}(4 + 4) + \frac{1}{9}(9 + 9 + 9)\]
\[Var[W] = \frac{8}{4} + \frac{27}{9} = 5\]
Question 4:
A company wants to compare the efficiency of two types of fuel for a car. 5 identical cars will be driven 500 kilometers each, two with the first type of fuel and three with the second type. Let \(X_1\) and \(X_2\) be the observed fuel efficiency for the first type and \(Y_1\), \(Y_2\), and \(Y_3\) be the efficiency for the second type. Suppose these variables are independent and:
- \(X_i \sim N(20, 4)\) for \(i = 1, 2\)
- \(Y_j \sim N(18, 9)\) for \(j = 1, 2, 3\)
Define a new random variable:
\[ W = \frac{X_1 + X_2}{2} - \frac{Y_1 + Y_2 + Y_3}{3} \]
Find \(P(W \geq 0)\). Round your answer to four decimal places.
Answer
0.8145
We’ve now fully defined \(W \sim N(2, 5)\)
So it’s just the pnorm()
lookup. (1 - the result since it’s asking for the right side.)
<- 2
mean_W <- 5
var_W <- sqrt(var_W)
sd_W
1 - pnorm(0, mean_W, sd_W)
<- 2
mean_W <- 5
var_W <- sqrt(var_W)
sd_W
1 - pnorm(0, mean_W, sd_W)