MSDS Summer Bridge 2018 Data Science Math - HW 2
Jeff Littlejohn, 7/21/2018

Note: Had issues using Latex with combinatorics.
1. There are 540 identical plastic chips numbered 1 through 540 in a box. What is the probability of reaching into the box and randomly drawing the chip numbered 505? Express your answer as a fraction or a decimal number rounded to four decimal places. \[P(505) = \frac{1}{540}\]

2. Write out the sample space for the given experiment. Separate your answers using commas.
When deciding what you want to put into a salad for dinner at a restaurant, you will choose one of the following extra toppings: asparagus, cheese. Also, you will add one of following meats: eggs, turkey. Lastly, you will decide on one of the following dressings: French, vinaigrette. (Note: Use the following letters to indicate each choice: A for asparagus, C for cheese, E for eggs, T for turkey, F for French, and V for vinaigrette.)
\[S = {(A,E,F),(A,E,V),(A,T,F),(A,T,V),(C,E,F),(C,E,V),(C,T,F),(C,T,V)}\]:

3. A card is drawn from a standard deck of 52 playing cards. What is the probability that the card will be a heart and not a face card? Write your answer as a fraction or a decimal number rounded to four decimal places. \[Event A = {heart}\] \[Event B = {heart face cards}\] \[P(A \cap B) = P(A) * P(B|A)\] \[P(A \cap B) = \frac{13}{52} * \frac{10}{13} = \frac{130}{676} = \frac{5}{26} \]

4. A standard pair of six-sided dice is rolled. What is the probability of rolling a sum less than 6? Write your answer as a fraction or a decimal number rounded to four decimal places.

library(prob)
## Loading required package: combinat
## 
## Attaching package: 'combinat'
## The following object is masked from 'package:utils':
## 
##     combn
## Loading required package: fAsianOptions
## Loading required package: timeDate
## Loading required package: timeSeries
## Loading required package: fBasics
## 
## Rmetrics Package fBasics
## Analysing Markets and calculating Basic Statistics
## Copyright (C) 2005-2014 Rmetrics Association Zurich
## Educational Software for Financial Engineering and Computational Science
## Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
## https://www.rmetrics.org --- Mail to: info@rmetrics.org
## Loading required package: fOptions
## 
## Rmetrics Package fOptions
## Pricing and Evaluating Basic Options
## Copyright (C) 2005-2014 Rmetrics Association Zurich
## Educational Software for Financial Engineering and Computational Science
## Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
## https://www.rmetrics.org --- Mail to: info@rmetrics.org
## Loading required package: hypergeo
## Loading required package: VGAM
## Loading required package: stats4
## Loading required package: splines
## 
## Attaching package: 'VGAM'
## The following object is masked from 'package:hypergeo':
## 
##     is.zero
## The following object is masked from 'package:fAsianOptions':
## 
##     erf
## 
## Attaching package: 'prob'
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, union
f4 <- rolldie(2)
f4
##    X1 X2
## 1   1  1
## 2   2  1
## 3   3  1
## 4   4  1
## 5   5  1
## 6   6  1
## 7   1  2
## 8   2  2
## 9   3  2
## 10  4  2
## 11  5  2
## 12  6  2
## 13  1  3
## 14  2  3
## 15  3  3
## 16  4  3
## 17  5  3
## 18  6  3
## 19  1  4
## 20  2  4
## 21  3  4
## 22  4  4
## 23  5  4
## 24  6  4
## 25  1  5
## 26  2  5
## 27  3  5
## 28  4  5
## 29  5  5
## 30  6  5
## 31  1  6
## 32  2  6
## 33  3  6
## 34  4  6
## 35  5  6
## 36  6  6


\(6 x 6 = 36\) possible outcomes Spaces that have sum less than 6: \({(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(2,3),(3,1),(3,2),(4,1)}\) \[P(sum < 6) = \frac{10}{36} = \frac{5}{18}\]

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

rn5 = c("Apartments","Dorm","With Parent(s)","Sorority/Fraternity House","Other")
a5 = c(233,159,102,220,250)
b5 = c(208,138,280,265,146)
df5 = data.frame(rn5,a5,b5)
colnames(df5) = c("Residence Type","Male","Female")
df5
##              Residence Type Male Female
## 1                Apartments  233    208
## 2                      Dorm  159    138
## 3            With Parent(s)  102    280
## 4 Sorority/Fraternity House  220    265
## 5                     Other  250    146


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

m5 <- sum(df5$Male)
m5
## [1] 964
t5 <- sum(df5$Male) + sum(df5$Female)
t5
## [1] 2001

\[P(male) = \frac{964}{2001}\]

6. Three cards are drawn with replacement from a standard deck. What is the probability that the first card will be a club, the second card will be a black card, and the third card will be a face card? Write your answer as a fraction or a decimal number rounded to four decimal places.
\[P(club) = \frac{1}{4}\] \[P(black) = \frac{1}{2}\] \[P(face) = \frac{3}{13}\] With replacement, order matters

(1/4) * (1/2) * (3/13)
## [1] 0.02884615
3/104
## [1] 0.02884615

\[P = \frac{3}{104}\]

7.Two cards are drawn without replacement from a standard deck of 52 playing cards. What is the probability of choosing a spade for the second card drawn, if the first card, drawn without replacement, was a heart? Write your answer as a fraction or a decimal number rounded to four decimal places. \[P(spade|heart) = \frac{13}{51}\]

8. Two cards are drawn without replacement from a standard deck of 52 playing cards. What is the probability of choosing a heart and then, without replacement, a red card? Write your answer as a fraction or a decimal number rounded to four decimal places. \[P(heart then red card) = \frac{13}{52} * \frac{25}{51}\]

(13/52) * (25/51)
## [1] 0.122549
13 * 25
## [1] 325
52 * 51
## [1] 2652
25/204
## [1] 0.122549

\[P(heart then red card) = \frac{25}{204}\]

9. There are 85 students in a basic math class. The instructor must choose two students at random.

Students in a Basic Math Class Males Females Freshmen 12 12 Sophomores 19 15 Juniors 12 4 Seniors 7 4

rn9 = c("Freshmen","Sophmores","Juniors","Seniors")
a9 = c(12,19,12,7)
b9 = c(12,15,4,4)
df9 = data.frame(rn9,a9,b9)
colnames(df9) = c("Year","Male","Female")
df9
##        Year Male Female
## 1  Freshmen   12     12
## 2 Sophmores   19     15
## 3   Juniors   12      4
## 4   Seniors    7      4

What is the probability that a junior female and then a freshmen male are chosen at random? Write your answer as a fraction or a decimal number rounded to four decimal places.

tot9 <- sum(df9$Male) + sum(df9$Female)
tot9
## [1] 85

\[P(junior female then freshman male) = \frac{4}{85} * \frac{12}{84}\]

(4/85) * (12/84)
## [1] 0.006722689
84 * 85
## [1] 7140
48/7140
## [1] 0.006722689
4/595
## [1] 0.006722689

\[P(junior female then freshman male) = \frac{4}{595}\]

10.Out of 300 applicants for a job, 141 are male and 52 are male and have a graduate degree.
Step 1. What is the probability that a randomly chosen applicant has a graduate degree, given that they are male? Enter your answer as a fraction or a decimal rounded to four decimal places.
\[P(grad degree|male) = \frac{52}{141}\]
Step 2. If 102 of the applicants have graduate degrees, what is the probability that a randomly chosen applicant is male, given that the applicant has a graduate degree? Enter your answer as a fraction or a decimal rounded to four decimal places. \[P(male|grad degree) = \frac{52}{102} = \frac{26}{51}\]

11. A value meal package at Ron’s Subs consists of a drink, a sandwich, and a bag of chips. There are 6 types of drinks to choose from, 5 types of sandwiches, and 3 types of chips. How many different value meal packages are possible?
Multiplication rule of counting

6 * 5 * 3
## [1] 90

90

12. A doctor visits her patients during morning rounds. In how many ways can the doctor visit 5 patients during the morning rounds?
Factorial rule of counting

factorial(5)
## [1] 120

\[5! = 120\]

13. A coordinator will select 5 songs from a list of 8 songs to compose an event’s musical entertainment lineup. How many different lineups are possible?
Assuming order does not matter - Combination: \[C(n,r) = \frac{n!}{(n-r)!r!}\]

factorial(8)/(factorial(8-5) * factorial(5))
## [1] 56

56
Assuming order matters - Permutation: \[P(n,r) = \frac{n!}{(n-r)!}\]

factorial(8)/factorial(8-5)
## [1] 6720

6720

14. A person rolls a standard six-sided die 9 times. In how many ways can he get 3 fours, 5 sixes and 1 two?

This is wrong, but I will keep looking into it.

Total outcomes\(= 6^9 = 10077696\) Getting 3 fours: \(9_C_3 = \frac{1}{6}^3 * (1-\frac{1}{6})^{9-3}\) Getting 5 sixes: \(9_C_5 = \frac{1}{6}^5 * (1-\frac{1}{6})^{9-5}\) Getting 1 two: \(9_C_1 = \frac{1}{6}^1 * (1-\frac{1}{6})^{9-1}\)

\[(\frac{1}{6})^3 * (\frac{5}{6})^6 * (\frac{1}{6})^5 * (\frac{5}{6})^4 * (\frac{1}{6}) * (\frac{5}{6})^8}\]

(1/6)^3 * (5/6)^6 * (1/6)^5 * (5/6)^4 * (1/6) * (5/6)^8
## [1] 3.727145e-09



15. How many ways can Rudy choose 6 pizza toppings from a menu of 14 toppings if each topping can only be chosen once?
Combination: \[C(n,r) = \frac{n!}{(n-r)!r!}\]

factorial(14)/(factorial(14-6) * factorial(6))
## [1] 3003



16. 3 cards are drawn from a standard deck of 52 playing cards. How many different 3-card hands are possible if the drawing is done without replacement?
\[C(n,r) = \frac{n!}{(n-r)!r!}\]

factorial(52)/(factorial(52-3) * factorial(3))
## [1] 22100



17. You are ordering a new home theater system that consists of a TV, surround sound system, and DVD player. You can choose from 12 different TVs, 9 types of surround sound systems, and 5 types of DVD players. How many different home theater systems can you build?
Multiplication rule of counting

12 * 9 * 5
## [1] 540

540

18. You need to have a password with 5 letters followed by 3 odd digits between 0 - 9 inclusively. If the characters and digits cannot be used more than once, how many choices do you have for your password?

26 * 25 * 24 * 23 * 22 * 10 * 9 * 8
## [1] 5683392000

5683392000

19. Evaluate the following expression.
\[ 9P_4\]??? Permutation: \[P(n,r) = \frac{n!}{(n-r)!}\]

factorial(9)/factorial(9-4)
## [1] 3024

3024

20. Evaluate the following expression.
\[11C_8\] \[C(n,r) = \frac{n!}{(n-r)!r!}\]

factorial(11)/(factorial(11-8) * factorial(8))
## [1] 165

165

21. Evaluate the following expression.
\[\frac{12P_8}{12C_4}\]

p21 <- factorial(12)/factorial(12-8)
c21 <- factorial(12)/(factorial(12-4) * factorial(4))
p21/c21
## [1] 40320

40320

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

factorial(13)/(factorial(13-7)*factorial(7))
## [1] 1716

1716

23. In how many ways can the letters in the word ‘Population’ be arranged? 10 letters - 2 letters included twice

factorial(10)/(factorial(2) * factorial(2))
## [1] 907200

907200

24. Consider the following data:

x24 = c(5,6,7,8,9)
px24 = c(.1,.2,.3,.2,.2)
df24 = data.frame(x24,px24)
colnames(df24) = c("x","p(x)")
df24
##   x p(x)
## 1 5  0.1
## 2 6  0.2
## 3 7  0.3
## 4 8  0.2
## 5 9  0.2

Step 1. Find the expected value (\(Ex\)). Round your answer to one decimal place.

exp24 <- sum(x24*px24)
exp24
## [1] 7.2


Step 2. Find the variance. Round your answer to one decimal place.

var24 <- sum((x24 - exp24)^2 * px24)
var24
## [1] 1.56


Step 3. Find the standard deviation. Round your answer to one decimal place.

sd24 <- var24^(1/2)
sd24
## [1] 1.249


Step 4. Find the value of (X>=9). Round your answer to one decimal place.
.2
Step 5. Find the value of (X <= 7). Round your answer to one decimal place. .6

25. Suppose a basketball player has made 188 out of 376 free throws. If the player makes the next 3 free throws, I will pay you $23. Otherwise you pay me $4.
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.

#Odds of making next 3 free throws
(188/376)^3
## [1] 0.125
x25 = c(23,-4)
px25 = c(.125,.875)
df25 = data.frame(x25,px25)
colnames(df25) = c("x","p(x)")
df25
##    x  p(x)
## 1 23 0.125
## 2 -4 0.875
exp25 <- sum(x25*px25)
round(exp25,2)
## [1] -0.62


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

exp25 * 994
## [1] -621.25



26. Flip a coin 11 times. If you get 8 tails or less, I will pay you $1. Otherwise you pay me $7.
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
Reworded - Get tails 9, 10, or 11 times - I pay $7.

#prob of tails 8 or fewer times
px26lt9 <- pbinom(8,11,.5)
#prob of tails 9-11 times
px26gte9 <- 1 - px26lt9
#expected value
exp26 <- px26lt9 * 1 + px26gte9 * -7
exp26
## [1] 0.7382812

Expected value = $.74
Step 2. If you played this game 615 times how much would you expect to win or lose? (Losses must be entered as negative.)

round(615 * exp26,2)
## [1] 454.04

Win $454.04

27. If you draw two clubs on two consecutive draws from a standard deck of cards you win $583. Otherwise you pay me $35. (Cards drawn without replacement.)
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.

#prob of consecutive clubs drawn w/o replacement
px27c <- (13/52) * (12/51)
#prob of complement
px27nc <- 1 - px27c
#expected value
exp27 <- px27c * 583 + px27nc * -35
round(exp27,2)
## [1] 1.35

Expected value is $1.35 per game.
Step 2. If you played this game 632 times how much would you expect to win or lose? (Losses must be entered as negative.)

round(exp27 * 632,2)
## [1] 855.06

Win $855.06

28. A quality control inspector has drawn a sample of 10 light bulbs from a recent production lot. If the number of defective bulbs is 2 or less, the lot passes inspection. Suppose 30% of the bulbs in the lot are defective. What is the probability that the lot will pass inspection? (Round your answer to 3 decimal places)

round(pbinom(2,10,.3),3)
## [1] 0.383



29. A quality control inspector has drawn a sample of 5 light bulbs from a recent production lot. Suppose that 30% of the bulbs in the lot are defective. What is the expected value of the number of defective bulbs in the sample? Do not round your answer.

5 * .3
## [1] 1.5




30. The auto parts department of an automotive dealership sends out a mean of 5.5 special orders daily. What is the probability that, for any day, the number of special orders sent out will be more than 5? (Round your answer to 4 decimal places)

# P(X>5)
round(ppois(5, 5.5,lower.tail = FALSE), 4)
## [1] 0.4711



31. At the Fidelity Credit Union, a mean of 5.7 customers arrive hourly at the drive-through window. What is the probability that, in any hour, more than 4 customers will arrive? (Round your answer to 4 decimal places)

# P(X>4)
round(ppois(4, 5.7,lower.tail = FALSE), 4)
## [1] 0.6728



32. The computer that controls a bank’s automatic teller machine crashes a mean of 0.4 times per day. What is the probability that, in any 7-day week, the computer will crash no more than 1 time? (Round your answer to 4 decimal places)

# P(X<=1)
round(ppois(1, 2.8), 4)
## [1] 0.2311



33. A town recently dismissed 8 employees in order to meet their new budget reductions. The town had 6 employees over 50 years of age and 19 under 50. If the dismissed employees were selected at random, what is the probability that more than 1 employee was over 50? Write your answer as a fraction or a decimal number rounded to three decimal places.

#P(q>=1)
#more than 1 employee
q <- 1
#6 employees over 50
m <- 6
#19 under 50
n <- 19
#8 fired
k <- 8
#lower.tail because P[X > x]
P33 <- phyper(q, m, n, k, lower.tail = F)
round(P33, 3)
## [1] 0.651



34. Unknown to a medical researcher, 10 out of 25 patients have a heart problem that will result in death if they receive the test drug. Eight patients are randomly selected to receive the drug and the rest receive a placebo. What is the probability that less than 7 patients will die? Write your answer as a fraction or a decimal number rounded to three decimal places.

#fewer than 7 will die
q34 <- 6
#10 will die with test drug
m34 <- 10
#15 won't die with test drug
n34 <- 15
#8 receive test drug in trial
k34 <- 8
P34 <- phyper(q34, m34, n34, k34)
round(P34, 3)
## [1] 0.998