2.5 Coin flips.

If you flip a fair coin 10 times, what is the probability of

  1. getting all tails?

    \(P(\text{tails})=\frac{1}{2}\)
    \(P(10\text{ tails})=(\frac{1}{2})^{10}=\) 0.0009765625

  2. getting all heads?

    Same as above; probability of heads and tails are equal in a fair coin. \(P(\text{heads})=\frac{1}{2}\)
    \(P(10\text{ heads})=(\frac{1}{2})^{10}=\) 0.0009765625

  3. getting at least one tails?

    The complement of getting all heads out of ten coin flips is getting at least one tails.
    \(P(\geq1\text{ tails})=1-P(10\text{ heads})=1-(\frac{1}{2})^{10}=\) 0.9990234

2.8 Poverty and language.

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.

  1. Are living below the poverty line and speaking a foreign language at home disjoint?

    No, it is possible to be simultaneously living below the poverty line while speaking a language other than English at home. 4.2% of the sample fall into ball categories.

  2. Draw a Venn diagram summarizing the variables and their associated probabilities.
    https://cran.r-project.org/web/packages/VennDiagram/

library(VennDiagram)
grid.newpage()
draw.pairwise.venn(14.6, 20.7, 4.2, 
                   category = c("live below the poverty line", "language other than English at home"), 
                   lty = rep("blank", 2), 
                   fill = c("light blue", "light green"), 
                   alpha = rep(0.5, 2), 
                   cat.pos = c(.5, 0.5), 
                   cat.dist = rep(0.025, 2))

## (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?
    10.4% of Americans live below the poverty line and only speak English at home.
  2. What percent of Americans live below the poverty line or speak a foreign language at home?
    31.1% of Americans live below the poverty line or speak a foreign language at home.
  3. What percent of Americans live above the poverty line and only speak English at home?
    68.9% of Americans live above the poverty line and only speak English at home.
  4. Is the event that someone lives below the poverty line independent of the event that the person speaks a foreign language at home?
    No, the events are dependent. Given independent events A and B,
    \(P(A\cap B))=P(A)P(B)\). For \(P(A\cap B))=.042, P(A)=.146 \text{ and } P(B)=.207, 0.042\neq0.030222\)

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.

a. What is the probability that a randomly chosen male respondent or his partner has blue eyes?

mating <- read.csv("https://raw.githubusercontent.com/jbryer/DATA606Fall2016/master/Data/Data%20from%20openintro.org/Ch%202%20Exercise%20Data/assortive_mating.csv")
table(mating)
##          partner_female
## self_male blue brown green
##     blue    78    23    13
##     brown   19    23    12
##     green   11     9    16
tot<-nrow(mating)
p_blue<-(sum(mating$self_male=="blue")/tot)+(sum(mating$partner_female=="blue")/tot)-(sum(mating$self_male=="blue"&mating$partner_female=="blue")/tot)
cat("Probability that a male respondent or his partner has blue eyes is",p_blue)
## Probability that a male respondent or his partner has blue eyes is 0.7058824
  1. What is the probability that a randomly chosen male respondent with blue eyes has a partner with blue eyes?
tot_mblue<-sum(mating$self_male=="blue")
p_pblue<-(sum(mating$self_male=="blue"&mating$partner_female=="blue")/tot_mblue)
cat("Probability that a male respondent and his partner has blue eyes is",p_pblue)
## Probability that a male respondent and his partner has blue eyes is 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?
tot_mbrown<-sum(mating$self_male=="brown")
p_dblue<-(sum(mating$self_male=="brown"&mating$partner_female=="blue")/tot_mbrown)
cat("Probability that a male respondent with brown eyes has a partner with blue eyes is",p_dblue,"\n")
## Probability that a male respondent with brown eyes has a partner with blue eyes is 0.3518519
tot_mgreen<-sum(mating$self_male=="green")
p_gblue<-(sum(mating$self_male=="green"&mating$partner_female=="blue")/tot_mgreen)
cat("Probability that a male respondent with green eyes has a partner with blue eyes is",p_gblue)
## Probability that a male respondent with green eyes has a partner with blue eyes is 0.3055556
  1. Does it appear that the eye colors of male respondents and their partners are independent? Explain your reasoning.

    For \(P(\text{mate blue}|\text{male brown}))=\) 0.3518519, and \(P(\text{mate blue})=\) 0.5294118, the condition of the male respondent’s eye color affects the probability that the partner’s eye color is blue; therefore the events are not independent.

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.

bk<-read.csv("https://raw.githubusercontent.com/jbryer/DATA606Fall2016/master/Data/Data%20from%20openintro.org/Ch%202%20Exercise%20Data/books.csv")
table(bk)
##             format
## type         hardcover paperback
##   fiction           13        59
##   nonfiction        15         8
  1. Find the probability of drawing a hardcover book first then a paperback fiction book second when drawing without replacement.
totbk<-sum(nrow(bk))
p_hd_pbfic<-((sum(bk$format=="hardcover"))/totbk)*((sum(bk$format=="paperback"&bk$type=="fiction"))/(totbk-1))
cat("The probability of drawing a hardcover book first\n then a paperback fiction book second without replacement is",p_hd_pbfic)
## The probability of drawing a hardcover book first
##  then a paperback fiction book second without replacement is 0.1849944
  1. Determine the probability of drawing a fiction book first and then a hardcover book second, when drawing without replacement.
p_fic_hdc<-((sum(bk$type=="fiction"))/totbk)*((sum(bk$format=="hardcover"))/(totbk-1))
cat("The probability of drawing a fiction book first\n then a hardcover book second without replacement is",p_fic_hdc)
## The probability of drawing a fiction book first
##  then a hardcover book second without replacement is 0.2257559
  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.
p_fic_hdc<-((sum(bk$type=="fiction"))/totbk)*((sum(bk$format=="hardcover"))/(totbk))
cat("The probability of drawing a fiction book first\n then a hardcover book second with replacement is",p_fic_hdc)
## The probability of drawing a fiction book first
##  then a hardcover book second with replacement is 0.2233795
  1. The final answers to parts (b) and (c) are very similar. Explain why this is the case.
    One book of 95 is a small percentage and doesn’t effect the probability significantly.

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.

  1. Build a probability model, compute the average revenue per passenger, and compute the corresponding standard deviation.
num_luggage<-c(0,1,2)
prob_pass<-c(.54,.34,.12)
fee<-c(0,25,60)
luggage<-data.frame(num_luggage,prob_pass,fee)
luggage$prob_fee<-luggage$prob_pass*luggage$fee

revenue<-sum(luggage$prob_fee)
cat("Average revenue per passenger is $",revenue,"\n")
## Average revenue per passenger is $ 15.7
stdev<-sqrt((.54*(0-revenue)^2)+(.34*(25-revenue)^2)+(.12*(60-revenue)^2))
cat("Corresponding standard deviation is",stdev)
## Corresponding standard deviation is 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.
cat("Total revenue for 120 passengers is $",revenue*120,"\n")
## Total revenue for 120 passengers is $ 1884
stdev<-sqrt((.54*(0-revenue)^2)+(.34*(25-revenue)^2)+(.12*(60-revenue)^2))
cat("Corresponding standard deviation is",stdev)
## Corresponding standard deviation is 19.95019

Standard deviation is consistent with the average cost per passenger; we are assuming that the flight follows the probability model we’ve constructed.

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.

  1. 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)
library(kableExtra)
kable(data.frame(income,total))
income total
$1 to $9,999 2.2
$10,000 to $14,999 4.7
$15,000 to $24,999 15.8
$25,000 to $34,999 18.3
$35,000 to $49,999 21.2
$50,000 to $64,999 13.9
$65,000 to $74,999 5.8
$75,000 to $99,999 8.4
$100,000 or more 9.7
barplot(total)


The distribution is multimodal and somewhat skewed. Median is 9.7 and mean is 11.1111111.

  1. What is the probability that a randomly chosen US resident makes less than $50,000 per year?
atpi<-data.frame(income,total)
atpi$recode<-seq.int(nrow(atpi))
p_50K<-sum(atpi$total[ which(atpi$recode <= 5)])/100
cat("Probability that a resident makes less than $50K is",p_50K)
## Probability that a resident makes less than $50K is 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.

Probability that a female resident makes less than $50K is 0.25502; this assumes that females and males have roughly equal equivalent income distribution.

  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.
    If 71.8% of women make less than $50K the distribution of wealth among women and men differs significantly and the probability calculated in c needs adjustment.