1)Dice Rolls

#(a) probability of sum of 1
0/36
## [1] 0
#(b) probability of sum of 5
4/36
## [1] 0.1111111
#(c) probability of sum of 12
1/36
## [1] 0.02777778
  1. School Absences
one_day <- .25
two_days <- .15
three_plus_days <- .28

#(a) probability of no missed days
no_days <- 1-(one_day + two_days + three_plus_days)
no_days
## [1] 0.32
#(b) prob of missing no more than 1 day
no_days+one_day
## [1] 0.57
#(c) prob of missing at least 1 day
1-no_days
## [1] 0.68
#(d) prob that neither kid will miss any school
#ASSUMPTION: BOTH KIDS HAVE EQUAL PROBABILITY & BOTH EVENTS INDEPENDENT
no_days * no_days
## [1] 0.1024
#(e) prob both kids will miss some school
#ASSUMPTION: BOTH KIDS HAVE EQUAL PROBABILITY & BOTH EVENTS INDEPENDENT
(1-no_days * 1-no_days)
## [1] 0.36
#(f): do you think assumption was reasonable?
print("Assumption of both events being independant is NOT reasonable due to propensity of sickness transmission within household. If one is sick, probability is higher for the second kid getting sick")
## [1] "Assumption of both events being independant is NOT reasonable due to propensity of sickness transmission within household. If one is sick, probability is higher for the second kid getting sick"
  1. Health coverage, relative frequencies
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")

#(a) Are being in excellent health and having health coverage mutually exclusive?
print("No")
## [1] "No"
#(b) probability that a randomly chosen individual has excellent health?
sum(mat[,"Excellent"])
## [1] 0.2329
#(c) probability that a randomly chosen individual has excellent health given that he has health coverage?
mat["Coverage","Excellent"]/sum(mat["Coverage",])
## [1] 0.2402152
#(d) What is the probability that a randomly chosen individual has excellent health given that he doesn’t have health coverage?
mat["No Coverage","Excellent"]/sum(mat["No Coverage",])
## [1] 0.1821061
#(e) Do having excellent health and having health coverage appear to be independent?
print("Yes")
## [1] "Yes"
  1. Exit Poll
#probability that he voted in favor of Scott Walker given college degree
vote_for <- .53
vote_against <- 1-vote_for
college_vote_for <- vote_for * .37
college_vote_against <- vote_against * .44
college_degree <- college_vote_for + college_vote_against

#probability of voting in favor of Scott Walker given college degree
college_vote_for/college_degree
## [1] 0.4867213
  1. Books on a bookshelf
mymat2=matrix(c(13,59,15,8),nrow=2,byrow=TRUE)
colnames(mymat2)=c("hard","paper")
rownames(mymat2)=c("fiction","nonfiction")

#(a)hardcover first, ppr second w/o replacement
ttl_books <- sum(mymat2)
sum(mymat2[,"hard"])/ttl_books * (mymat2["fiction","paper"]/(ttl_books-1))
## [1] 0.1849944
#(b) fiction book first 'a' and then a hardcover book 'b',when drawing without replacement.
a <- (mymat2["fiction","hard"]/ttl_books)*((mymat2[,"hard"]-1)/(ttl_books-1))
b <- (mymat2["fiction","paper"]/ttl_books)*(mymat2[,"hard"]/(ttl_books-1))
sum(a,b)
## [1] 0.2228443
#(c) fiction book first 'a' and then a hardcover book second'b',when drawing without replacement.
a <- sum(mymat2["fiction",])/ttl_books
b <- (sum(mymat2[,"hard"]))/(ttl_books) 
a*b
## [1] 0.2233795
#(d) what are c & d similar?
print("This is because not replacing 1 book out of 95 has a minimal effect")
## [1] "This is because not replacing 1 book out of 95 has a minimal effect"
  1. Is it worth it?
#(a) Create a probability model and find Andy’s expected profit per game.
#outcomes
a <- 36/52 * -2
b <- 12/52 * 1
c <- 3/52 * 3
d <- 1/52 *  18
sum(a,b,c,d)
## [1] -0.6346154
#(b) Would you recommend this game to Andy as a good way to make money? Explain.
print("I wouldn't recommend it since Andy is expected to lose ~63 cents per game")
## [1] "I wouldn't recommend it since Andy is expected to lose ~63 cents per game"
  1. Scooping ice cream Ice cream usually comes in 1.5 quart boxes (48 fluid ounces), and ice cream scoops hold about 2 ounces. However, there is some variability in the amount of ice cream in a box as well as the amount of ice cream scooped out. We represent the amount of ice cream in the box as X and the amount scooped out as Y . Suppose these random variables have the following means, standard deviations, and variances:
mymat3=matrix(c(48,1,1, 2,.25,.0625), nrow=2, byrow=TRUE)
colnames(mymat3)=c("mean", "SD", "Var")
rownames(mymat3)=c("X, In Box","Y, Scooped")
mymat3
##            mean   SD    Var
## X, In Box    48 1.00 1.0000
## Y, Scooped    2 0.25 0.0625
#(a) An entire box, plus 3 scoops is served, How much ice cream do you expect to have been served? What is the standard deviation of the amount of ice cream served?
print(48+2+2+2)
## [1] 54
sqrt(1+.0625+.0625+.0625)
## [1] 1.089725
#(b) How much ice cream would you expect to be left in the box after scooping out one scoop of ice cream? That is, find the expected value of X ??? Y . What is the standard deviation of the amount left in the box?
print(48-3)
## [1] 45
sqrt(1+.0625)
## [1] 1.030776
#(c) Using the context of this exercise, explain why we add variances when we subtract one random variable from another.
print("because each variable is affected by its own variance whether adding or subtracting that variable, so the cumulative amount has the cumulative variance")
## [1] "because each variable is affected by its own variance whether adding or subtracting that variable, so the cumulative amount has the cumulative variance"