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.
#1. Number of Red Marbles
R = 54
#2. Number of White Marbles
W=9
#3. Number of Blue Marbles.
B=75

# Total Marbles 
T = R + W + B

#Probability of R
Pr = R/T

#Probability of W
Pw = W/T

#Probability of B
Pb = B/T

# Probability of P(R or B)

Pr + Pb
## [1] 0.9347826
  1. 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.
#1. Number of Green Balls
G = 19
#2. Number of Red Balls
R=20
#3. Number of Blue Balls
B=24
#4. Number of Yellow Balls
Y = 17

# Total Number of Balls 
T = G + R + Y + B

#Probability of R
Pr = R/T
Pr
## [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.

Male = c(81,116,215,130,129)
Fem = c(228, 79, 252, 97,72)
Category = c("Apartments","Dorm","With Parents", "Soro-Frat","Other")


# Step 1: Probability that customre is not a male.

sum(Fem)/(sum(Male)+sum(Fem))
## [1] 0.5203717
# Step 2: Conditional Probability that customer does not stay's with Parents

TotWithParents = 215 + 252

TotWithParents/(sum(Male)+sum(Fem))
## [1] 0.3338099

4.Determine if the following events are independent. Going to the gym. Losing weight.

# Ans : These are Independent. Though they seem to be dependent.

# Going to Gym does not gaurantee you that there will be weight loss, because the weight loss could happen just with diet/or some health issue
# Or any other condition depending on the Individual. So They are two independent events.
  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?
#1. Number of Vegetables 
V = 8
#2. Number of Condiments 
C = 7
#1. Number of Tortilla 
T = 3

# Since we have 3 Tortilla. We can pick 8 Vegetables.

Combvt = choose(8,3) 

# Since we have 3 Tortilla. We can pick 7 Condiments.

Combct = choose(7,3)
# Number of Veggie Wraps Combvt * Combct * T

Nvw =  Combvt * Combct * choose(3,1)
Nvw
## [1] 5880
  1. Determine if the following events are independent. Jeff runs out of gas on the way to work. Liz watches the evening news.
# Since we are talking about two different people we cannot have any correlation between them.
# Hence these 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?

# Number of candidates eligible for position.

Nc = 14

# Number of cabinet position available 
Np = 8

# Different Appointments Since Rank Matters, we have to do Permutation. n!/(n-r)!

factorial(Nc)/factorial(Nc-Np)
## [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.
#1. Number of Red Jellybeans
R = 9
#2. Number of Orange Jellybeans
O=4
#3. Number of Green Jellybeans
G = 9

# Total Number of Jelly Bean 
T = G + R + O

# Choosing 3 Greens from 9

chooseG = choose(9,3)

# Choosing 1 Orange from 4

chooseO = choose(4,1)

# choose 0 from 9

chooseR = choose(9,0)

# choose 4 from Total Sample Space

chooseSpace = choose(22,4)

# P = Size of event space/Size of Sample Space

P = (chooseG * chooseO * chooseR)/chooseSpace
P
## [1] 0.04593301
  1. Evaluate the following expression. 11!/7!
factorial(11)/factorial(7)
## [1] 7920
  1. Describe the complement of the given event. 67% of subscribers to a fitness magazine are over the age of 34.
# Number of Subscribers > 34

Subgrtr34 = 67/100

# We know Subgrtr34 + Sublesseq34 = 1, Since Sum of Complement + Non-Complement = 1

Sublesseq34 = 1 - Subgrtr34
Sublesseq34
## [1] 0.33
  1. 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. Step 2. If you played this game 559 times how much would you expect to win or lose? (Losses must be entered as negative.)
# Total Number of Possible Outcomes out of 4 tosses.
# Outcome for one toss = 2
# Therefore the outcome for 4 tosses will be equal to 2 * 2* 2* 2

TotOutcome = 2 * 2* 2 *2 

# Out of 4 tosses, we want to see whether 3 heads are in there. 
# For that we are getting first all possible combinations of heads outcome

TotalHeadOutcome = choose(4,3)

# Probability of getting 3 heads of four toses.

P = TotalHeadOutcome/TotOutcome
P
## [1] 0.25
# From this we can see there is 25% chance of of Winning 97$ and 75% Chance of ending pay the guy $30

#Step 1: The Expected Value of this is
Ex = (97) * .25 + (-30) * .75
Ex
## [1] 1.75
# Step 2 : If Played 559 times

559 * Ex
## [1] 978.25
  1. 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. Step 2. If you played this game 994 times how much would you expect to win or lose? (Losses must be entered as negative.)
# Total Number of Possible Outcomes out of 9 tosses.
# Outcome for one toss = 2
# Therefore the outcome for 9 tosses will be equal to 2^9

TotOutcome = 2^9 

# Out of 9 tosses, we want to see how many 4 or less tails are in there. 
# For that we are getting first all possible combinations of tails outcome

TotalTailOutcome = choose(9,4) + choose(9,3) + choose(9,2) + choose(9,1)

# Probability of getting 4 or less tails of 9 toses.

P = TotalTailOutcome/TotOutcome
P
## [1] 0.4980469
# From this we can see there is 49% chance of winning $23 or 51% chance of loosing $26

#Step 1: The Expected Value of this is
Ex = (23) * P + (-26) * (1-P)
Ex
## [1] -1.595703
# Step 2 : If Played 994 times

round((994 * Ex),0)
## [1] -1586
  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.)
  2. 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.)
  3. 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.
#1. The value of Senstivity and Specificity are given as .59 and .90 respectively

# Probability of Folks who lie P(L) = .20

PL = .20

# Probability of Folks who do not lie P(No Lie) = 1-.20 = .80

PNL = .80

# Probability of detecting Liar Senstivity = P(Lie Detect) = .59

PLD = .59

# Probability of Not Detecting Lie P(Not Lie Detect) = 1=.59 = .41

PNLD = .41

# Probability of Telling Truth Specificity P(Truth) = .90

PT = .90

# Probability of Not Telling Truth P(Not Truth) = 1-.90 = .1

PNT = 1-PT


# Q1. Probability a Person is Liar and the test detected same.

PLGivenD = (PLD * PL)/((PL * PLD) + (PNL * PNT))
PLGivenD
## [1] 0.5959596
# Q2. Probability a Person is Truth Teller and test detected same.

TruthTeller = (PT * PNT)/((PL * PNLD) + (PNL * PT))
TruthTeller
## [1] 0.1122195
# Q3. Either a Liar or Test identifier Liar

# P(A U B) = P(A) + P(B) - P(A) and P(B)