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:

total_marbles = 54+9+75
prob_red_blue = (54+75)/total_marbles
round(prob_red_blue,2)
## [1] 0.93

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: It is a permutation repeat problem assumed there is no different among of same collor balls. Hower, we can think in this way - since the last position is red and regardless the color and orders of peviouse 79 balls, there are 20 choices of red for the last position, which compaes to the 80 choices of total balls. The probability is 20/80 = 1/4 =0.25.

The answer is solved by count of permutation repeat as following: The total number of listing the first 79 balls (19 green + (20-1) red + 24 blue + 17 yellow) is 79!/(19!*19!*24!*17!)

The totall number of listing all 80 balls is 80!/(19!*20!*24!*17!)

so the probability of last ball is red is #listing 79 balls/#listing 80 balls

#(79!/(19!*19!*24!*17!)) / (80!/(19!*20!*24!*17!))
#after simpulfy
20/80
## [1] 0.25
  1. 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.

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.

index = c('Apartment','Dorm','With Parent(s)','Sorority/Fraternity House','Other')
males = c(81,116,215,130,129)
females = c(228,79,252,97,72)
sex=cbind(males,females)
df = cbind(index, sex)
colnames(df) <- c("", "Males", "Females")
df
##                                  Males Females
## [1,] "Apartment"                 "81"  "228"  
## [2,] "Dorm"                      "116" "79"   
## [3,] "With Parent(s)"            "215" "252"  
## [4,] "Sorority/Fraternity House" "130" "97"   
## [5,] "Other"                     "129" "72"
#P(X=a customer is not male or does not live with parents)
prob_x=(228+79+252+97+72+81+116+130+129)/(228+79+252+97+72+81+116+215+130+129)
round(prob_x,2)
## [1] 0.85

4.Determine if the following events are independent. Event A is going to the gym. Event B is losing weight.

By definition of independent, if A and B are independent while 1) both events have positive probability and P(A|B)= p(A) and P(B|A)=P(B) or 2) at least one of the probability is 0. Also, A and B are independent if and only if P(A intersect B) = P(A)*P(B)

Answer: Since one of the ways to lost weight is do more exercise and one of results to gym is losing weight, I can’t tell P(A intersect B)=P(A)*P(B)=0 and P(A|B)=P(A) or P(B|A)=P(B). So they are dependent.

  1. 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: It’s a combination problem.

#pick 3 different vegetables from 8 is 8!/3!5!
#pick 3 different condiments from 7 is 7!/3!4!
#pick 1 tortilla from 3 is combn(3,1) 3!/1!2!

((8*7*6)/(3*2))*((5*7*6)/(3*2))*3
## [1] 5880

6.Determine if the following events are independent. Event A is that Jeff runs out of gas on the way to work. Event B is that Liz watches the evening news.

Answer: I can tell event A happened whatever whether event B happended, that means P(B) can be zero. By the definition of independent, A and B are 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:It’s a combination and permutation problem.

# choose 8 candidates from 14  14!/8!6!
# 8 positions are in different ranks  8!

#after simpulfy the answer 14!8!/8!6!
14*13*12*11*10*9*8*7
## [1] 121080960
  1. 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.

Ansewer:It is a combination problem.

# choose 0 red from 9  9!/0!9!
# choose 1 orange from 4  4!/1!3!
# choose 3 green from 9  9!/3!6!
# choose 4 from all (9+4+9)!/4!18!

#after simpulfy the answer 
prob_jellbeans=((4*9*8*7)/(3*2))/((22*21*20*19)/(4*3*2))

round(prob_jellbeans,2)
## [1] 0.05
  1. Evaluate the following expression. 11!/7!
(11*10*9*8*7*6*5*4*3*2)/(7*6*5*4*3*2)
## [1] 7920
  1. Describe the complement of the given event. 67% of subscribers to a fitness magazine are over the age of 34.

Answer: The complement of the event is that 33% of subscribers to a fitness magazine who are not over the age of 34 and 100% of unsubscriber to a fitness magazine who are in any age.

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.

Answer: binomial probabitity b(n,p,k) The probability of a head in each tosses is equal to get a tail if the coin is a fair coin. So P(H=head) = P(T=tail) = 1/2 =0.5

# 3 heads from four tosses is 4!/3!1!
# other events (H=0,1,2,4) from four tosses is 4!/0!4! + 4!/1!3! + 4!/2!/2! +4!/4!0!

#after simpulfy the answer 
4*0.5^4*(97) + (1+4+6+1)* 0.5^4 * (-30)
## [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.)

# expect value is 10.8125
# 559 times 

559 * (1.75)
## [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.

Answer: binomial probabitity b(n,p,k) The probability of a head in each tosses is equal to get a tail if the coin is a fair coin. So P(H=head) = P(T=tail) = 1/2 =0.5

# 4 tails or less from 9 tosses is 
#9!/4!5! + 9!/3!6! +9!/2!7! +9!/1!8! + 9!/0!/9!
# other events (T=5,6,7,8,9) from 9 tosses is 
#9!/5!4! + 9!/6!3! +9!/7!2! +9!/1!8! + 9!/0!/9!

#The number of chance you get 4 or less tails is equal to more than 4 tails. after simpulfy the answer 
(9*2*7+3*4*7+9*4+9+1)*0.5^9*(23-26)
## [1] -1.5

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

# expect value is -1.5
# 994 times 

994 * (-1.5)
## [1] -1491
  1. 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.
  1. 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.)

Method #1 Bayes Answer: Given P(detec_liar | is_liars) = 0.59 and , so P(detec_liar and is_liars) = 0.59 * P(is_liars). Another, given P(detec_true | is_ture) = 0.9, so P(detec_ture and is_true) = 0.9 * P(is_ture).

Since we estimate total liars is 20%, total ture is 80%. So P(detec_liar and is_liars ) = 0.59 * 0.2= 0.118 and P(detec_ture and is_true) = 0.9 * 0.8 0.72.

As the result, type I error and type II error can be calculated: P(detec_ture and is_liar) = 0.8 - 0.72 =0.08 and P(detec_liar and is_true) = 0.2 - 0.118=0.082

#P(is_liar |detec_liar )= P(is_liar and detec_liar )/ P(detec_liar)  
#=P(detec_liar | is_liars)* P(is_liar)/P(detec_liar) 
0.59 *(0.08+0.118)/ 0.2
## [1] 0.5841
#P(A|B) = P(B|A) *P(A) / (P(B|A)*P(A) + P(B|A^c)*P(A^c)))
  1. 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.)
#P(is_true |detec_true )= P(is_true and detec_true )/ P(detec_true)  
#=P(detec_true | is_ture)* P(is_true)/P(detec_true)

0.9*(0.72+0.082)/0.8
## [1] 0.90225
  1. 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: the probability is total % of liar, 0.28 (0.08+0.118+0.2-0.118), since P(A= is_liar) + P(B=detec_liar) - P( A intersect B).

Method #2

Answer: It’s conditional probability. Given P(detec_liar | is_liars) = 0.59 sensitivity and , so P(detec_liar) / P(Fail_detec_liar + detec_liar) = 0.59 . Another, given P(detec_true | is_ture) = 0.9, so P(detec_ture)/ P(Fail_detec_true + detec_true) = 0.9.

Since we estimate total liars is 20%, total ture is 80%. So P(detec_liar + Fail_detec_true ) = 0.2 and P(detec_ture + Fail_detec_liar) = 0.8.

As the result, to find all probabilities can be calculated:

#P(detec_liar) / P(Fail_detec_liar + detec_liar) =  0.59
#P(detec_ture)/ P(Fail_detec_true + detec_true) = 0.9
#P(detec_all_ture) = P(detec_ture + Fail_detec_liar) = 0.8
#P(detec_all_liar) = P(detec_liar + Fail_detec_true ) = 0.2

#P(Fail_detec_liar) 0.08369
#P(detec_liar) = 0.12041
#P(Fail_detec_true) = 0.7959
#P(detec_true) = 0.71631

#P(is_liar| detec_all_liar) = P(detec_liar)/P(detec_all_liar) = 0.12041 / 0.2 = 0.60205
  1. 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.)
#P(is_true| detec_all_true) = P(detec_true)/P(detec_all_true) = 0.71631 / 0.8 = 0.89539
  1. 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: the probability is total % of liar, 0.28369 ( P(Fail_detec_liar + detec_liar + Fail_detec_true ) = 0.08369+0.12041+0.07959 = 0.28369 ).