##Plot for 1.40. I drew one manually but wanted to try it on R
productivity <-   c(1,.8,.7,.75,.8,.5,.1,.1,.2,.2,.4,.55,.2,.4)
stress<- c(.5,.6,.65,.5,.55,.4,1,.1,.3,.9,.3,.6,.2,.8)

prod.df <- data.frame(productivity, stress)
library(ggplot2)
ggplot(prod.df, aes(stress, productivity)) + geom_point() + geom_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Probability Problems

## 2.6 Dice Rolls
#a- No pair of dice can sum up to 1
pofone <- 0
pofone
## [1] 0
#b- Pair has to roll either (1,4) or (2,3) to sum up to 5
poffive <- 4/36
poffive
## [1] 0.1111111
#c. Pair has to roll (6, 6) to sum up to 12
poftwelve <- 1/36
poftwelve
## [1] 0.02777778
## 2.12 School Absences
#a. Total students-Students that missed days
a <- 1-(0.25+0.15+0.28)
a
## [1] 0.32
#b Students that missed one day + Students that missed zero days
0.25+a
## [1] 0.57
#c Students that missed days
b <- 0.25+0.15+0.28
b
## [1] 0.68
#d Siblings both not missing days assuming independent events
a^2
## [1] 0.1024
#e Siblings both missing days assuming independent events
b^2
## [1] 0.4624
#f on word doc

##2.18 Health Coverage
mat=matrix(c(.023, 0.0364, 0.0427, 0.0192, 0.0050,0.2099, 0.3123 ,0.2410 ,0.0817,0.0289), byrow=TRUE, nrow=2)
colnames(mat)=c("Excellent", "Very Good","Good", "Fair","Poor")
rownames(mat)=c("No Coverage","Coverage")
mat 
##             Excellent Very Good   Good   Fair   Poor
## No Coverage    0.0230    0.0364 0.0427 0.0192 0.0050
## Coverage       0.2099    0.3123 0.2410 0.0817 0.0289
#a On word doc
#b Probability of Excellent health= Excellent health with/without health coverage
e <-0.2099+0.0230
e
## [1] 0.2329
#c Excellent Health given Health coverage= P(Both)/P(Health coverage total)
f <-0.2099/0.8738
f
## [1] 0.2402152
#d Excellent health given No coverage= P(Both)/P(No coverage total)
g <- 0.0230/0.1262
g
## [1] 0.1822504
#e On word doc

## 2.24 Exit Poll
# Probability of voting for Scott walker (A) given they are college student(B)=((P(A)*P(B|A))+P(A’)*P(B|A’)) 
h <- 0.53*0.37/((0.53*0.37)+(0.47*0.44))
h
## [1] 0.4867213
## 2.30 Books on a Bookshelf
#a Probability of drawing hardcover book first, paperback fiction second
x<- (28/95)*(59/94)
x
## [1] 0.1849944
#b Probability of drawing fiction book first, hardcover book second
y <-(72/95)*(28/94)
y
## [1] 0.2257559
#c Same as b but book is placed back on shelf
z <- (72/95)*(28/95)
z
## [1] 0.2233795
#d On word doc

## 2.36 Is it worth it?
#a Expected Profit per game= E(Loss)+E(Winning $3)+E(winning $5)+E(winning $20)- the $2 he pays each game
profit <- ((9/13)*0)+((3/13)*3)+((1/13)*5)+((1/52)*20)-2
profit
## [1] -0.5384615
#b On word doc

## 2.42 Scooping Ice Cream
#a One whole box and 3 scoops of Ice cream. Expected Total and standard deviation
tot <-(1*48)+(3*2)
tot
## [1] 54
sd <- sqrt(1+0.0625*3)
sd
## [1] 1.089725
#b One box minus one scoop. Expected Total and standard deviation 
totnew <- (1*48)-(1*2)
totnew
## [1] 46
sdnew <- sqrt(1+0.0625)
sdnew
## [1] 1.030776
#c On word doc