Homework 06

Week06 Problem Set -01
Solution01
red_marbles   <- 54
white_marbles <- 9
blue_marbles  <- 75
total_marbles <- red_marbles + white_marbles + blue_marbles
Probability_red_marbles   <- round(red_marbles/total_marbles, 4)
Probability_white_marbles <- round(white_marbles/total_marbles, 4)
Probability_blue_marbles  <- round(blue_marbles/total_marbles, 4)
Probability_red_or_blue_marbles <- round(Probability_red_marbles + Probability_blue_marbles, 4)

print(Probability_red_marbles)
## [1] 0.3913
print(Probability_white_marbles)
## [1] 0.0652
print(Probability_blue_marbles)
## [1] 0.5435
print(Probability_red_or_blue_marbles)
## [1] 0.9348

Probability of (Red or Blue) marble = Probability of Red marble + Probability of Blue marble = \(\frac{54}{54+9+75} + \frac{75}{54+9+75} = \frac{129}{138} = \frac{43}{46} = 0.9348\)

Therfore, the probability or red or blue marble = \(0.9348\)

Separator - 01
Week06 Problem Set -02
Solution02
green_balls  <- 19
red_balls    <- 20
blue_balls   <- 24
yellow_balls <- 17
total_balls  <- green_balls + red_balls + blue_balls + yellow_balls
Probability_red_balls <- round(red_balls/total_balls, 4)
print(Probability_red_balls)
## [1] 0.25

Probability of red balls = (# of red balls)/(total balls) = \(\frac{20}{19+20+24+17} = \frac{20}{80} = \frac{1}{4} = 0.25\)

Therfore, the probability that you end up with a red golf ball = \(0.25\)

Separator - 02
Week06 Problem Set -03
Solution03

Total # of customers N = 1399
We can use the formula: P( A U B) = P(A) + P(B) - P(A and B)
P(not male or does not live their parents) = P(female) + P(does not live with parents) - P(female and does not live with parents) / total N
P(A) = P(female) = \(\frac{(228+79+252+97+72)}{1399} = \frac{728}{1399} = 0.5203\)
P(B) = P(does not live with parents) = \(\frac{(1399-215-252)}{1399} = \frac{932}{1399} = 0.6662\)
P(A and B) = P(female and does not live with parents) = \(\frac{228+79+252+97+72-252)}{1399} = \frac{476}{1399} = 0.3402\)
P( A U B) = P(A) + P(B) - P(A and B) = \(0.5203\) + \(0.6662\) - \(0.3402\) = \(0.8463\)

Therefore, the probability that a customer is not male or does not live with parents = \(0.8463\)

Separator - 03
Week06 Problem Set -04
Solution04

When you go to the gym you excercise. This results in weight loss. Therefore, these are Dependent events.

Separator - 04
Week06 Problem Set -05
Solution05

\({8}\choose{3}\).\({7}\choose{3}\).\({3}\choose{1}\) = \(56.35.3\) = \(5880\)

# 3 vegetables are chosen from 8 different vegetables
vegetables <- choose(8, 3)

# 3 condiments are chosen from 7 different condiments
condiments <- choose(7, 3)

# 1 tortilla is chosen from 3 different tortillas
tortilla   <- choose(3, 1)

x <- vegetables * condiments * tortilla
print (x)
## [1] 5880
Separator - 05
Week06 Problem Set -06
Solution06

There is no relationship between the 2 events: Jeff running out of gas and Liz watching evening news.
Therefore, these are Independent events.

Separator - 06
Week06 Problem Set -07
Solution07

Since rank matters it is a permutation problem.
\(14 P_8\) = \(\frac{14!}{(14-8)!}\) = \(121080960\)

x <- factorial (14) / factorial (14-8)
print (x)
## [1] 121080960
\(121080960\)
Separator - 07
Week06 Problem Set -08
Solution08

Jelly Beans: 9 Red, 4 Orange, 9 Green
Total Jelly Beans: 22

\(\begin{aligned} \frac{{{9}\choose{0}}.{{4}\choose{1}}.{{9}\choose{3}}}{{22}\choose{4}} = \frac{1.4.84}{7315} = \frac{336}{7315} = 0.04593 \end{aligned}\)

\(0.04593\)

Separator - 08
Week06 Problem Set -09
Solution09

\(\begin{aligned} \frac{11!}{7!} = \frac{11.10.9.8.7!}{7!} = 11.10.9.8 = 7920 \end{aligned}\)

print(factorial(11)/factorial(7))
## [1] 7920
Separator - 09
Week06 Problem Set -10
Solution10

The compliment of this is 33% of subscribers to a fitness magazine are 34 or younger.

Separator - 10
Week06 Problem Set -11
Solution11
Step 1

For four coin tosses, there are 16 different cases:

#  Outcome   # of Heads   Probability of Heads 
 01  TTTT 0 0/4
 02  TTTH 1 1/4
 03  TTHT 1 1/4
 04  TTHH 2 2/4
 05  THTT 1 1/4
 06  THTH 2 2/4
 07  THHT 2 2/4
 08  THHH 3 3/4
 09  HTTT 1 1/4
 10  HTTH 2 2/4
 11  HTHT 2 2/4
 12  HTHH 3 3/4
 13  HHTT 2 2/4
 14  HHTH 3 3/4
 15  HHHT 3 3/4
 16  HHHH 4 4/4


Out of 16 possibilities, there are 4 chances of getting 3 heads.
Therefore the probability of getting 3 heads is 4/16. And the probability of not getting 3 heads is 12/16.

X  $97   -$30 
 P(X)  4/16 12/16


E(X) = \(\frac{4}{16}.(97)\) + \(\frac{12}{16}.(-30)\)
E(X) = \(\frac{1}{4}.(97)\) + \(\frac{3}{4}.(-30)\)
E(X) = \(24.25-22.5 = 1.75\)

Therefore, the Expected Value of the proposition is \(1.75\)

Step 2

This is the product of the number of times this game is played and the expected value calculated in Step 1.

E(X) = \(559\) X \(\ 1.75\) = \(\$978.25\)

If the game is played \(559\) times, the Expected Value of the proposition is \(\$978.25\)

Separator - 11
Week06 Problem Set -12
Solution12
Step 1
y <- pbinom(4, size=9, prob=0.5)
y
## [1] 0.5
expval <- round(23*y - 26*(1-y), 2)
expval
## [1] -1.5

The Expected Value of the proposition is \(-\$1.5\)

Step 2
expval994 <- expval * 994
expval994
## [1] -1491

If the game is played \(994\) times, the Expected Value of the proposition is \(\$-1491\)

Separator - 12
Week06 Problem Set -13
Solution13
actual_lie = 0.59 * 0.2
actual_truth = (1-0.90) * 0.8
actual_total = actual_lie+actual_truth
detected_lie = (1-0.59) * 0.2
detected_truth = 0.90 * 0.8 
detected_total = detected_lie + detected_truth

r1 = c(actual_lie, actual_truth, actual_total)
r2 = c(detected_lie, detected_truth, detected_total)
r3 = c(actual_lie + detected_lie, actual_truth + detected_truth, actual_total + detected_total)

print (r1)
## [1] 0.118 0.080 0.198
print (r2)
## [1] 0.082 0.720 0.802
print (r3)
## [1] 0.2 0.8 1.0
    Lie    Truth    Total  
 Actual    0.118   0.08   0.198 
 Detected    0.082   0.72   0.802 
 Total   0.2   0.8   1 
(a)
print(actual_lie/actual_total)
## [1] 0.5959596

The probability that an individual is actually a liar given that the polygraph detected him/her as such is \(0.5959596\)

(b)
print(detected_truth/detected_total)
## [1] 0.8977556

The probability that an individual is actually a truth-teller given that the polygraph detected him/her as such is \(0.8977556\)

(c)
print((actual_lie + detected_lie) + (actual_total) - (actual_lie))
## [1] 0.28

The probability that a randomly selected individual is either a liar or identified as a liar by the polygraph is \(0.28\)

Separator - 13