Chapter 2 - Probability
Graded: 2.6, 2.8, 2.20, 2.30, 2.38, 2.44
2.6 2.6 Dice rolls. If you roll a pair of fair dice, what is the probability of (a) getting a sum of 1? (b) getting a sum of 5? (c) getting a sum of 12? (Page 116).
a) getting a sum of 1?
for dice 1: n_dice_1 = number showing on dice 1; p_dice_1 = posibility of showing certain number on dice 1
n_dice_1 <- c(1,2,3,4,5,6)
p_dice_1 <- c(1/6,1/6,1/6,1/6,1/6,1/6)
For dice 2: n_dice_2 = number showing on dice 2; p_dice_2 = posibility of showing certain number on dice 2
n_dice_2 <- c(1,2,3,4,5,6)
P_dice_2 <- c(1/6,1/6,1/6,1/6,1/6,1/6)
sum_dices: sumb of dice 1 and dice 2; p_sum: posiblicites for each sum
sum_dices <- c(2,3,4,5,6,7,8,9,10,11,12)
p_sum<- c(1/36, 2/36, 3/36, 4/36, 5/36, 6/36, 5/36, 4/36, 3/36, 2/36, 1/36)
Let’s build the table
dicef <- data.frame(sum_dices, p_sum)
names(dicef) <- c("Sums", "Probability")
dicef
## Sums Probability
## 1 2 0.02777778
## 2 3 0.05555556
## 3 4 0.08333333
## 4 5 0.11111111
## 5 6 0.13888889
## 6 7 0.16666667
## 7 8 0.13888889
## 8 9 0.11111111
## 9 10 0.08333333
## 10 11 0.05555556
## 11 12 0.02777778
answer: Because the number on the dice from 1 through 6, the minum of the sum of two dices is 2. So it is impossible to get a sum of 1 by rolling two dices. The probability to get sum of 1 is zero.
- getting a sum of 5? For this, we have different possibilities: Let’s say X, Y represent the numbers on the first die and the second die, respectively. The possiblilities to get sum of 5 are the followings: Outcome 1 = P(X=1) * P(Y=4) = 1/6 * 1/6 = 1/36 Outcome 2 = P(X=2) * P(Y=3) = 1/6 * 1/6 = 1/36 Outcome 3 = P(X=3) * P(Y=2) = 1/6 * 1/6 = 1/36 Outcome 4 = P(X=4) * P(Y=1) = 1/6 * 1/6 = 1/36 So, There are 4 possible ways (1 & 4, 2 & 3, 3 & 2, 4 & 1) to obtain a sum of 5. P(X+Y = 5) = Outcome 1 + Outcome 2 + Outcome 3 + Outcome 4 P(X+Y = 5) = 1/36 + 1/36 + 1/36 + 1/36 P(X+Y = 5) = 4/36 = 0.1111111 So the possibility of getting sum of 5 is 4/36 or 0.1111111.
4/36
## [1] 0.1111111
- getting a sum of 12? For this, we only have one possibility (both dices are 6): Let’s say X represent the first die and Y the second die. The possible outcomes will be as follows: Outcome 1 = P(X=6) * P(Y=6) = 1/6 * 1/6 = 1/36 P(X+Y = 1) = 1/36
(1/6)*(1/6)
## [1] 0.02777778
answer: the possiblity to get sume of 12 is 1/36 or 0.02777778
2.20 Assortative mating. Assortative mating is a nonrandom mating pattern where individuals with similar genotypes and/or phenotypes mate with one another more frequently than what would be expected under a random mating pattern. Researchers studying this topic collected data on eye colors of 204 Scandinavian men and their female partners. The table below summarizes the results. For simplicity, we only include heterosexual relationships in this exercise.65 (Page 121).
- What is the probability that a randomly chosen male respondent or his partner has blue eyes?
108/204 + 114/204 - 78/204
## [1] 0.7058824
- What is the probability that a randomly chosen male respondent with blue eyes has a partner with blue eyes?
78/114
## [1] 0.6842105
- What is the probability that a randomly chosen male respondent with brown eyes has a partner with blue eyes?
19/54
## [1] 0.3518519
What about the probability of a randomly chosen male respondent with green eyes having a partner with blue eyes?
11/36
## [1] 0.3055556
- Does it appear that the eye colors of male respondents and their partners are independent? Explain your reasoning.
P(Blue Eye Males) x P(Blue Eye Females) = (114/204) x (108/204) = 0.296 (assuming independence). However, we know that P(Blue Eye males and Blue Eye Females) in this data set = (78/204) = 0.382, which is not equal. Thus this is dependent.
2.30 Books on a bookshelf. The table below shows the distribution of books on a bookcase based on whether they are nonfiction or fiction and hardcover or paperback.(Page 123).
Extract Data
books <- read.csv("https://raw.githubusercontent.com/jbryer/DATA606Fall2016/master/Data/Data%20from%20openintro.org/Ch%202%20Exercise%20Data/books.csv")
table(books)
## format
## type hardcover paperback
## fiction 13 59
## nonfiction 15 8
- Find the probability of drawing a hardcover book first then a paperback fiction book second when drawing without replacement.
(sum(books$format == "hardcover")/nrow(books)) * (sum(books$format == "paperback" & books$type == "fiction")/(nrow(books)-1) )
## [1] 0.1849944
- Determine the probability of drawing a fiction book first and then a hardcover book second, when drawing without replacement.
(sum(books$type == "fiction")/nrow(books)) * (sum(books$format == "hardcover")/(nrow(books)-1) )
## [1] 0.2257559
- Calculate the probability of the scenario in part (b), except this time complete the calculations under the scenario where the first book is placed back on the bookcase before randomly drawing the second book.
(sum(books$type == "fiction")/nrow(books)) * (sum(books$format == "hardcover")/nrow(books) )
## [1] 0.2233795
- The final answers to parts (b) and (c) are very similar. Explain why this is the case. #The sample sizes are large enough (95 versus 1) where if you take one book out, it would be negligible in the overall calculations.
2.38 Baggage fees. An airline charges the following baggage fees: $25 for the first bag and $35 for the second. Suppose 54% of passengers have no checked luggage, 34% have one piece of checked luggage and 12% have two pieces. We suppose a negligible portion of people check more than two bags.
- Build a probability model, compute the average revenue per passenger, and compute the corresponding standard deviation.
BagFee <- c(0, 25, 60)
Prob <- c(.54, .34, .12)
Expected.Value <- (BagFee[1] * Prob[1]) + (BagFee[2] * Prob[2]) + (BagFee[3] * Prob[3])
Variance <- 0
i <- 1
while (i <= length(BagFee)){
temp <- ((BagFee[i] - Expected.Value)^2 * Prob[i])
Variance <- Variance + temp
i <- i + 1
}
round(Expected.Value,2)
## [1] 15.7
round(Variance, 2)
## [1] 398.01
SD <- sqrt(Variance)
round(SD,2)
## [1] 19.95
- About how much revenue should the airline expect for a flight of 120 passengers? With what standard deviation? Note any assumptions you make and if you think they are justified.
EX120 <- 120 * Expected.Value
Var120 <- 120 * SD^2
SD120 <- sqrt(Var120)
round(EX120,2)
## [1] 1884
2.44 Income and gender. The relative frequency table below displays the distribution of annual total personal income (in 2009 inflation-adjusted dollars) for a representative sample of 96,420,486 Americans. These data come from the American Community Survey for 2005-2009. This sample is comprised of 59% males and 41% females.69 (a) Describe the distribution of total personal income. (b) What is the probability that a randomly chosen US resident makes less than $50,000 per year? (c) What is the probability that a randomly chosen US resident makes less than $50,000 per year and is female? Note any assumptions you make. (d) The same data source indicates that 71.8% of females make less than $50,000 per year. Use this value to determine whether or not the assumption you made in part (c) is valid.(Page 126).
- Describe the distribution of total personal income.
income <- c("$1 to $9,999","$10,000 to $14,999","$15,000 to $24,999","$25,000 to $34,999","$35,000 to $49,999","$50,000 to $64,999","$65,000 to $74,999","$75,000 to $99,999","$100,000 or more")
total <- c(2.2,4.7,15.8,18.3,21.2,13.9,5.8,8.4,9.7)
dist <- data.frame(income, total)
dist
## income total
## 1 $1 to $9,999 2.2
## 2 $10,000 to $14,999 4.7
## 3 $15,000 to $24,999 15.8
## 4 $25,000 to $34,999 18.3
## 5 $35,000 to $49,999 21.2
## 6 $50,000 to $64,999 13.9
## 7 $65,000 to $74,999 5.8
## 8 $75,000 to $99,999 8.4
## 9 $100,000 or more 9.7
barplot(dist$total, main="Income Distribution", xlab="% of Population")

answer: aunimodal with slight right skew.
- What is the probability that a randomly chosen US resident makes less than $50,000 per year?
(2.2 + 4.7 + 15.8 + 18.3 + 21.2) / 100
## [1] 0.622
- What is the probability that a randomly chosen US resident makes less than $50,000 per year and is female? Note any assumptions you make.
(2.2 + 4.7 + 15.8 + 18.3 + 21.2) / 100*0.41
## [1] 0.25502
- The same data source indicates that 71.8% of females make less than $50,000 per year. Use this value to determine whether or not the assumption you made in part (c) is valid.
(2.2 + 4.7 + 15.8 + 18.3 + 21.2) / 100*0.718
## [1] 0.446596
Part C states that .255 of the population are female and makes less than 50k. Here, in part D, this states that 71.8% of females made less than 50k. There is a huge discrepancy in the numbers, and thus it is not valid in part c.