Probability

2.6

Dice rolls. If you roll a pair of fair dice, what is the probability of
(a) getting a sum of 1?

# The probability of getting a sum of 1 is zero when rolling a pair of dice. The lowest possible sum when rolling two dice is 2.
  1. getting a sum of 5?
P(sum = 5) = P(1 & 4) or P(4 & 1) or P(3 & 2) or P(2 & 3)
P(sum = 5) = (1/36) * 4
(1/36) * 4
## [1] 0.1111111
  1. getting a sum of 12?
P(sum = 12) = P(6 & 6)
P(sum = 12) = (1/6)*(1/6)
(1/6)*(1/6)
## [1] 0.02777778

2.8

The American Community Survey is an ongoing survey that provides data every year to give communities the current information they need to plan investments and services. The 2010 American Community Survey estimates that 14.6% of Americans live below the poverty line, 20.7% speak a language other than English (foreign language) at home, and 4.2% fall into both categories.
(a) Are living below the poverty line and speaking a foreign language at home disjoint?

No because a person can both speak a foreign language and be living below the poverty line at the same time.
  1. Draw a Venn diagram summarizing the variables and their associated probabilities.
library(VennDiagram)
## Warning: package 'VennDiagram' was built under R version 3.4.4
## Loading required package: grid
## Loading required package: futile.logger
draw.pairwise.venn(area1 = 14.6,
                   area2 = 20.7,
                   cross.area = 4.2,
                   fill = c("yellow","green"),
                   category = c('Americans below poverty line', 'Foreign language'),
                   cat.dist = -0.1)

## (polygon[GRID.polygon.1], polygon[GRID.polygon.2], polygon[GRID.polygon.3], polygon[GRID.polygon.4], text[GRID.text.5], text[GRID.text.6], text[GRID.text.7], text[GRID.text.8], text[GRID.text.9])
  1. What percent of Americans live below the poverty line and only speak English at home?
The percent of Americans that live below the poverty line and only speak English can be calculated by subtracting the percent that fall into both catergories of speaking a foreign language and living below the poverty line from the percent of Americans living below the poverty line. We can also see this value in the above Venn diagram.  

14.6% - 4.2% = 10.4%
  1. What percent of Americans live below the poverty line or speak a foreign language at home?
(14.6 + 20.7) - 4.2
## [1] 31.1
  1. What percent of Americans live above the poverty line and only speak English at home?
100 - (14.6 + 20.7)
## [1] 64.7
  1. Is the event that someone lives below the poverty line independent of the event that the person speaks a foreign language at home?
Yes, the fact that someone is living below or above the poverty line does not influence whether or not the person speaks a foreign language at home.

2.20

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.

  1. What is the probability that a randomly chosen male respondent or his partner has blue eyes?
((total male w blue) + (total female w blue) - (both male and female w blue)) / (total)
(114 + 108 - 78) / 204
## [1] 0.7058824
  1. What is the probability that a randomly chosen male respondent with blue eyes has a partner with blue eyes?
P(female w blue | male w blue) = (both male and female w blue) / (total male w blue)
78 / 114
## [1] 0.6842105
  1. What is the probability that a randomly chosen male respondent with brown eyes has a partner with blue eyes? What about the probability of a randomly chosen male respondent with green eyes having a partner with blue eyes?
P(female w blue | male w brown) = (male w brown and female w blue) / (total male w brown)
19 / 54
## [1] 0.3518519
P(female w blue | male w green) = (male w green and female w blue) / (total male w green)
11 / 36
## [1] 0.3055556
  1. Does it appear that the eye colors of male respondents and their partners are independent? Explain your reasoning.
No, the observations above show that males and females are more likely to be with partners with the same eye color as themselves.

2.30

The table below shows the distribution of books on a bookcase based on whether they are nonfiction or fiction and hardcover or paperback.

  1. Find the probability of drawing a hardcover book first then a paperback fiction book second when drawing without replacement.
((hardcover total) / (total)) * ((paperback fiction) / (total - 1))
(28/95) * (59/94)
## [1] 0.1849944
  1. Determine the probability of drawing a fiction book first and then a hardcover book second, when drawing without replacement.
((fiction total) / (total)) + ((hardcover and first fiction hardcover) * (hardcover and first fiction paperback))
(72/95) * (((13/72)*(27/94)) + ((59/72)*(28/94)))
## [1] 0.2243001
  1. 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.
(72/95) * (((13/72)*(28/95)) + ((59/72)*(28/95)))
## [1] 0.2233795
  1. The final answers to parts (b) and (c) are very similar. Explain why this is the case.
The answers to B and C are similar because there is a large enough number of books on the bookcase that removing one and not replacing it before selecting a second book does not change the probabilities significantly.

2.38

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.

  1. Build a probability model, compute the average revenue per passenger, and compute the corresponding standard deviation.
prob <- c(.54, .34, .12)
bagfee <- c(0,25, 60)
df <- data.frame(bagfee,prob)
df$probtimesfee <- df$bagfee*df$prob
ex <- sum(df$probtimesfee)
# expected value or average revenue
ex
## [1] 15.7
df$fee_min_mean <-  df$bagfee - ex
df$sq_fee_min_mean <- df$fee_min_mean ** 2
df$sq_times_prob <- df$sq_fee_min_mean * df$prob

# variance
variance = sum(df$sq_times_prob)

# SD
sd = sqrt(variance)
sd
## [1] 19.95019
  1. 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.
We can assume that the expected revenue would be the avg expected revenue times the number of passengers and the same for the variance
ex * 120
## [1] 1884
sd * 120
## [1] 2394.023

2.44

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.

  1. Describe the distribution of total personal income.
income <- c('$1 - $9,999 or less', 
            '$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')
percenttotal = c(.022,
                 .047,
                 .158,
                 .183,
                 .212,
                 .139,
                 .058,
                 .084,
                 .097)

incomedf <- data.frame(income, percenttotal)
par(mar = c(12, 4,4,2))
barplot(incomedf$percenttotal, names.arg = incomedf$income, las =3)

  1. What is the probability that a randomly chosen US resident makes less than $50,000 per year?
sum(incomedf$percenttotal[0:5])
## [1] 0.622
  1. 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.
The sample was 41% female, therefore multiplying the answer from (b) by 0.41 shoudl give us the answer.
sum(incomedf$percenttotal[0:5]) * 0.41
## [1] 0.25502
  1. 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.
I would not consider the assumption I made in part (c) to be valid because the distribution of income between gender varies with income range.  In part (b) we calculated that 62.2% of the sample population is making less than 50k. Which means there this many people are earning below 50k from the sample:
96420486 * .62
## [1] 59780701
The number of females in the sample:
96420486 * .41
## [1] 39532399
Multiplying the number of females in the sample by 0.718 and then dividing by the number of people earning less than 50k returns 0.47 which differs from the 0.41 value given to us in part (c).
(39532399 * .718) / 59780701
## [1] 0.4748065