If you flip a fair coin 10 times, what is the probability of
getting all tails?
\(P(\text{tails})=\frac{1}{2}\)
\(P(10\text{ tails})=(\frac{1}{2})^{10}=\) 0.0009765625
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
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
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.
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.
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])
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
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
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
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
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
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
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
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.
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
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.
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.
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.
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
Probability that a female resident makes less than $50K is 0.25502; this assumes that females and males have roughly equal equivalent income distribution.