Chapter 2 - Probability Graded: 2.6, 2.8, 2.20, 2.30, 2.38, 2.44

#install.packages('VennDiagram')
library('VennDiagram')
## Loading required package: grid
## Loading required package: futile.logger

2.6 (a) getting a sum of 1?

#s={}
#P(s)=0
  1. getting a sum of 5?
#s={(1,4),(4,1),(2,3),(3,2)}
#p(s)=4/36 = 1/8
  1. getting a sum of 12?
#s={(6,6)}
#p(s)=1/36

2.8

pr_poor<-14.6/100 # %Americans live below the poverty line
pr_ESL<-20.7/100 # %speak a language other than English
pr_poorESL<-4.2/100 # %fall into both categories
  1. Are living below the poverty line and speaking a foreign language at home disjoint?
#No.
  1. Draw a Venn diagram summarizing the variables and their associated probabilities.
venn.plot <- draw.pairwise.venn(area1 = pr_poor,area2 = pr_ESL,cross.area = pr_poorESL,category = c("% Poor", "% ESL"),fill = c("light blue", "pink"));
grid.draw(venn.plot);

  1. What percent of Americans live below the poverty line and only speak English at home?
Ans<-pr_poor-pr_poorESL
Ans
## [1] 0.104
  1. What percent of Americans live below the poverty line or speak a foreign language at home?
Ans<-pr_poor+pr_ESL-pr_poorESL
Ans
## [1] 0.311
  1. What percent of Americans live above the poverty line and only speak English at home?
Ans<-1-(pr_poor+pr_ESL-pr_poorESL)
Ans
## [1] 0.689
  1. Is the event that someone lives below the poverty line independent of the event that the person speaks a foreign language at home?
Ans<-pr_poor-pr_poorESL
Ans
## [1] 0.104

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

ans<-108/204
ans
## [1] 0.5294118
  1. What is the probability that a randomly chosen male respondent with blue eyes has a partner with blue eyes?
ans<-78/204
ans
## [1] 0.3823529
  1. What is the probability that a randomly chosen male respondent with brown eyes has a partner with blue eyes?
ans<-19/204
ans
## [1] 0.09313725

What about the probability of a randomly chosen male respondent with green eyes having a partner with blue eyes?

ans<-11/204
ans
## [1] 0.05392157
  1. Does it appear that the eye colors of male respondents and their partners are independent? Explain your reasoning.
#No.Eye color of two male and female variable are joined together, female's eye color is depent on male's.

2.30 (a) Find the probability of drawing a hardcover book first then a paperback fiction book second when drawing without replacement.

ans<-(28/95)*(59/94)
ans
## [1] 0.1849944
  1. Determine the probability of drawing a fiction book first and then a hardcover book second, when drawing without replacement.
ans<-(72/95)*(28/94)+(72/95)*(27/94)
ans
## [1] 0.443449
  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.
ans<-(72/95)*(28/95)+(72/95)*(27/95)
ans
## [1] 0.4387812
  1. The final answers to parts (b) and (c) are very similar. Explain why this is the case.
#The difference is part b withou replacement and part c with replacement.With replacement, the probability of second object is picked also base on the complete data set. 

2.38 (a) Build a probability model, compute the average revenue per passenger, and compute the corresponding standard deviation.

avg<-25*0.34+(35+25)*0.12
avg
## [1] 15.7
var_x<-0.34*25^2+0.12*(35+25)^2-avg^2
standard_dev<-sqrt(var_x)
standard_dev
## [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.
#E(120x)=120*E(x)
E<-120*avg
E
## [1] 1884
standard_dev<-sqrt(120*var_x)
standard_dev
## [1] 218.5434

2.44 (a) Describe the distribution of total personal income.

#It is normal distribution, and mean is very closed to median.
  1. What is the probability that a randomly chosen US resident makes less than $50,000 per year?
ans<-0.022+0.047+0.158+0.183+0.212
ans
## [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.
#undefine
#We don't know the female or male 's saraly distribution. If data distribution is skew, the general probability can not represent one of female/male 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.
#My assumption in c is correct. The femail's saraly is left skew. 
ans<-0.718*0.41
ans
## [1] 0.29438