Grando 6 Homework

1. A box contains 54 red marbles, 9 white marbles, and 75 blue marbles. If a marble is randomly selected from the box, what is the probability that it is red or blue? Express your answer as a fraction or a decimal number rounded to four decimal places.

Answer:

The probability that a red or blue marble is selected from the set is the ratio of red and blue marbles to the total.

red_or_blue_marbles <- 54 + 75
total_marbles <- 54 + 9 + 75
(red_or_blue_probability <- round(red_or_blue_marbles/total_marbles, 4))
## [1] 0.9348

Alternatively, in fraction form, the probability is:

\[\frac { \left ( 54 + 75 \right) }{ \left ( 54 + 9 + 75 \right) } = \frac {129}{138}\]

2. You are going to play mini golf. A ball machine that contains 19 green golf balls, 20 red golf balls, 24 blue golf balls, and 17 yellow golf balls, randomly gives you your ball. What is the probability that you end up with a red golf ball? Express your answer as a simplified fraction or a decimal rounded to four decimal places.

Answer:

As mentioned above, we find the ratio of red golf balls to the total number

r_golfball <- 20
total_golfballs <- 19 + 20 + 24 + 17
(r_probability <- round(r_golfball/total_golfballs, 4))
## [1] 0.25

Again, in fraction form:

\[\frac { \left ( 20 \right) }{ \left ( 19 + 20 + 24 + 17 \right) } = \frac {20}{80}\]

3. A pizza delivery company classifies its customers by gender and location of residence. The research department has gathered data from a random sample of 1399 customers. The data is summarized in the table below.

library(knitr)
library(kableExtra)
pizza_df <- data.frame(Name = c("Apartment", "Dorm", "With_Parent", "Sorority/Fraternity_House", 
    "Other"), Male = c(81, 116, 215, 130, 129), Female = c(228, 79, 252, 97, 72))
kable(pizza_df, "html") %>% kable_styling(c("striped", "bordered")) %>% add_header_above(c(`Gender and Residence of Customers` = 3))
Gender and Residence of Customers
Name Male Female
Apartment 81 228
Dorm 116 79
With_Parent 215 252
Sorority/Fraternity_House 130 97
Other 129 72

What is the probability that a customer is not male or does not live with parents? Write your answer as a fraction or a decimal number rounded to four decimal places.

Answer:

To compute this probability, since the two events are not disjoint, we must add the probability of either event and subtract the probability of the combined event (i.e not male and does not live with parents)

prob_not_male <- sum(pizza_df$Female)/sum(pizza_df[, c("Male", "Female")])
prob_not_live_with_parents <- sum(pizza_df[pizza_df$Name != "With_Parent", c("Male", 
    "Female")])/sum(pizza_df[, c("Male", "Female")])
prob_both <- sum(pizza_df[pizza_df$Name != "With_Parent", c("Female")])/sum(pizza_df[, 
    c("Male", "Female")])
(prob_not_male_or_not_live_with_parents <- round(prob_not_male + prob_not_live_with_parents - 
    prob_both, 4))
## [1] 0.8463

In fraction form:

\[\frac{728}{1399} + \frac{932}{1399} - \frac{476}{1399} = \frac{1184}{1399}\]

4. Determine if the following events are independent.

Going to the gym. Losing weight.

Answer: A) Dependent B) Independent

While it may appear that one would lead to the other, it is not necessarily a fact that going to the gym will cause one to lose weight, they would have to exercise when they get there of course! However, if we knew someone had just started going to the gym, we may be able to predict a weight loss, all other things being equal.

5. A veggie wrap at City Subs is composed of 3 different vegetables and 3 different condiments wrapped up in a tortilla. If there are 8 vegetables, 7 condiments, and 3 types of tortilla available, how many different veggie wraps can be made?

Answer:

veggie_combs <- choose(8, 3)
cond_combs <- choose(7, 3)
tortilla_combs <- choose(3, 1)
(total_combs <- veggie_combs * cond_combs * tortilla_combs)
## [1] 5880

6. Determine if the following events are independent.

Jeff runs out of gas on the way to work. Liz watches the evening news.

Answer: A) Dependent B) Independent

Since Jeff running out of gas does not appear to influence any of Liz’s decisions, these events appear to be independent.

7. The newly elected president needs to decide the remaining 8 spots available in the cabinet he/she is appointing. If there are 14 eligible candidates for these positions (where rank matters), how many different ways can the members of the cabinet be appointed?

Answer:

Since rank matters, we are looking for the number of permuatations that can happen in this scenario. It does not appear that there is a builtin permuation function for R so we will calculate it manually:

(permuatations <- factorial(14)/(factorial(14 - 8)))
## [1] 121080960

Also, since the number of combinations is represented as the following formula:

\[\frac{n!}{\left( n - r\right)!r!}\]

we can simply multiply this result by r!:

(permuatations <- choose(14, 8) * factorial(8))
## [1] 121080960

8. A bag contains 9 red, 4 orange, and 9 green jellybeans. What is the probability of reaching into the bag and randomly withdrawing 4 jellybeans such that the number of red ones is 0, the number of orange ones is 1, and the number of green ones is 3? Write your answer as a fraction or a decimal number rounded to four decimal places.

Answer:

This is a description where the intersection of three separate combinations should be calculated (red = 0, orange = 1, and green = 3):

red_comb <- choose(9, 0)
orange_comb <- choose(4, 1)
green_comb <- choose(9, 3)
total_comb <- choose((9 + 4 + 9), 4)
(jelly_prob <- round((red_comb * orange_comb * green_comb)/total_comb, 4))
## [1] 0.0459

9. Evaluate the following expression. \[\frac { 11! }{ 7! } \]

Answer:

Since it was specifically asked to evaluate the function, I did it manually below:

\[\frac{11 * 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1}{7 * 6 * 5 * 4 * 3 * 2 * 1} = 11 * 10 * 9 * 8 = 7920\]

Verification:

(factorial(11)/factorial(7))
## [1] 7920

10. Describe the complement of the given event.

67% of subscribers to a fitness magazine are over the age of 34.

Answer:

34% of subscribers to a fitness magazine are 34 or younger.

11. If you throw exactly three heads in four tosses of a coin you win $97. If not, you pay me $30.

Step 1. Find the expected value of the proposition. Round your answer to two decimal places.

The value of the proposition is the probability of winning multiplied by the payout minus the probability of losing multiplied by the payin:

coin_win_combs <- choose(4, 3)
coin_total_combs <- 2^4
coin_win_prob <- coin_win_combs/coin_total_combs
(value <- round(coin_win_prob * 97 - (1 - coin_win_prob) * 30, 2))
## [1] 1.75

Step 2. If you played this game 559 times how much would you expect to win or lose? (Losses must be entered as negative.)

To determine the winnings/losses over a series of games, you simply mutliply the value by the number of times played

(559 * value)
## [1] 978.25

12. Flip a coin 9 times. If you get 4 tails or less, I will pay you $23. Otherwise you pay me $26.

Step 1. Find the expected value of the proposition. Round your answer to two decimal places.

As noted above, the following calculations are performed. However, this time, we win if we get 4 tails or less which means that we can add the disjoint probabilities of 1, 2, 3, or 4 tails.

coin_win_combs <- choose(9, 4) + choose(9, 3) + choose(9, 2) + choose(9, 1)
coin_total_combs <- 2^9
coin_win_prob <- coin_win_combs/coin_total_combs
(value <- round(coin_win_prob * 23 - (1 - coin_win_prob) * 26, 2))
## [1] -1.6

Step 2. If you played this game 994 times how much would you expect to win or lose? (Losses must be entered as negative.)

(994 * value)
## [1] -1590.4

13. The sensitivity and specificity of the polygraph has been a subject of study and debate for years. A 2001 study of the use of polygraph for screening purposes suggested that the probability of detecting a liar was .59 (sensitivity) and that the probability of detecting a “truth teller” was .90 (specificity). We estimate that about 20% of individuals selected for the screening polygraph will lie.

a. What is the probability that an individual is actually a liar given that the polygraph detected him/her as such? (Show me the table or the formulaic solution or both.)

Answer:

This is a question pertaining to conditional probability. Specifically, it is asking for:

\[P\left( liar|detected\_liar\right) = \frac{P\left( liar \cap detected\_liar \right)}{P\left( detected\_liar\right)}\]

\[=\frac{P\left( liar \cap detected\_liar \right)}{P\left( liar \cap detected\_liar \right) + P \left( truth \cap detected\_liar\right)} = \frac{0.59 * 0.2}{\left(0.59*0.2\right)+(1-0.2)*(1-0.9)}\]

\[= \frac{0.118}{0.198} = 0.5960\]

b. What is the probability that an individual is actually a truth-teller given that the polygraph detected him/her as such? (Show me the table or the formulaic solution or both.)

Answer:

As discussed above, the probability is:

\[P\left( truth|detected\_truth\right) = \frac{P\left( truth \cap detected\_truth \right)}{P\left( detected\_truth\right)}\]

\[=\frac{P\left( truth \cap detected\_truth \right)}{P\left( truth \cap detected\_truth \right) + P \left( liar \cap detected\_truth \right)} = \frac{\left( 1-0.2\right)*0.9}{\left( 1-0.2\right)*0.9 + 0.2 * \left( 1-0.59\right)}\]

\[= \frac{0.72}{0.802} = 0.8978\]

c. What is the probability that a randomly selected individual is either a liar or was identified as a liar by the polygraph? Be sure to write the probability statement.

Answer:

This question is asking for the probability of two events. First, is the person a liar; second, is the person identified as a liar. Therefore, we can add the two probabilities and subtract the intersection when both occur.

\[P\left( liar \cup detected\_liar \right) = P\left( liar \right) + P\left( detected\_liar \right) - P\left(liar \cap detected\_liar \right)\]

\[P\left( liar \cup detected\_liar \right) = 0.2 + \left( 0.2 \times 0.59 + 0.8 \times 0.1 \right) - \left( 0.2 \times 0.59 \right) = 0.28\]

p_liar <- 0.2
# both positive detections
p_detected_liar <- 0.2 * 0.59 + 0.8 * 0.1
p_liar_detected_liar <- 0.2 * 0.59
(p_liar_or_identified_liar <- p_liar + p_detected_liar - p_liar_detected_liar)
## [1] 0.28