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
#s={(1,4),(4,1),(2,3),(3,2)}
#p(s)=4/36 = 1/8
#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
#No.
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);
Ans<-pr_poor-pr_poorESL
Ans
## [1] 0.104
Ans<-pr_poor+pr_ESL-pr_poorESL
Ans
## [1] 0.311
Ans<-1-(pr_poor+pr_ESL-pr_poorESL)
Ans
## [1] 0.689
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
ans<-78/204
ans
## [1] 0.3823529
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
#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
ans<-(72/95)*(28/94)+(72/95)*(27/94)
ans
## [1] 0.443449
ans<-(72/95)*(28/95)+(72/95)*(27/95)
ans
## [1] 0.4387812
#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
#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.
ans<-0.022+0.047+0.158+0.183+0.212
ans
## [1] 0.622
#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.
#My assumption in c is correct. The femail's saraly is left skew.
ans<-0.718*0.41
ans
## [1] 0.29438