Problem 1

dice1 <- rep(1:6, 6)
dice2 <- c(rep(1, 6), rep(2, 6), rep(3, 6), rep(4, 6), rep(5, 6), rep(6, 6))
dice_sum <- dice1 + dice2
diceroll_sum <- function(x) length(dice_sum[dice_sum == x]) / length(dice_sum)

Problem 1-A

diceroll_sum(1)
## [1] 0

Problem 1-B

diceroll_sum(5)
## [1] 0.1111111

Problem 1-C

diceroll_sum(12)
## [1] 0.02777778

Problem 2

one_day <- 0.25
two_days <- 0.15
three_or_more <- 0.28

Problem 2-A

zero_days <- 1 - one_day - two_days - three_or_more
zero_days
## [1] 0.32

Problem 2-B

one_day + zero_days
## [1] 0.57

Problem 2-C

1 - zero_days
## [1] 0.68

Problem 2-D

# Assume that if one kid is absent, then that absent doesn't affect the other kid being absent. 

zero_days * zero_days
## [1] 0.1024

Problem 2-E

# Assume that if one kid is absent, then that absent affecta if the other kid will be absent.

1 - zero_days * zero_days - 2 * zero_days * (1 - zero_days)
## [1] 0.4624

Problem 2-F

Assumptions are listed above

Problem 3

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

Problem 3-A

r_mat <- cbind(mat, sum = rowSums(mat))
s_mat <- rbind(r_mat, sum = colSums(r_mat))
s_mat
##             Excellent Very Good   Good   Fair   Poor    sum
## No Coverage    0.0230    0.0364 0.0427 0.0192 0.0050 0.1263
## Coverage       0.2099    0.3123 0.2410 0.0817 0.0289 0.8738
## sum            0.2329    0.3487 0.2837 0.1009 0.0339 1.0001
# Not mutually exclusive
s_mat[2, 1]
## [1] 0.2099

Problem 3-B

s_mat[3, 1]
## [1] 0.2329

Problem 3-C

s_mat[2, 1] / s_mat[2, 6]
## [1] 0.2402152

Problem 3-D

s_mat[1, 1] / s_mat[1, 6]
## [1] 0.1821061

Problem 3-E

# Not independent since answer to problem 2-c does not equal to answer to problem 3-e

s_mat[3, 1] * s_mat[2, 6]
## [1] 0.203508

Problem 4

(.53 * .37) / ((.53 * .37) + (1 - .53) * .44)
## [1] 0.4867213

Problem 5

mymat2=matrix(c(13,59,15,8),nrow=2,byrow=TRUE)
colnames(mymat2)=c("hard","paper")
rownames(mymat2)=c("fiction","nonfiction")


mymat2
##            hard paper
## fiction      13    59
## nonfiction   15     8

Problem 5-A

r_mat <- cbind(mymat2, sum = rowSums(mymat2))
s_mat <- rbind(r_mat, sum = colSums(r_mat))
s_mat
##            hard paper sum
## fiction      13    59  72
## nonfiction   15     8  23
## sum          28    67  95
hardcover_book <- s_mat[3, 1] / s_mat[3, 3]
paperback_fiction <- s_mat[1, 2] / (s_mat[3, 3] - 1)
hardcover_book * paperback_fiction
## [1] 0.1849944

Problem 5-B

fiction_book <- s_mat[1, 3] / s_mat[3, 3]
hardcover_book2 <- s_mat[3, 1] / (s_mat[3, 3] - 1)
fiction_book * hardcover_book2
## [1] 0.2257559

Problem 5-C

fiction_book * hardcover_book
## [1] 0.2233795

Problem 5-D

The answers for problem 5-b and problem 5-c are similiar because of the sample size. If the sample size is large enough, then the denominator would change for both answers.

Problem 6

mat = matrix(c(32/52, 4/52, 4/52, 4/52, 3/52, 1/52, 0, 3, 3, 3, 5, 20, -2, 1, 1, 1, 3, 18), byrow=TRUE, nrow=3)
colnames(mat)=c("2-10", "jack", "queen", "king", "ace", "ace of clubs")
rownames(mat)=c("odds", "prize", "payout")
mat
##              2-10       jack      queen       king        ace ace of clubs
## odds    0.6153846 0.07692308 0.07692308 0.07692308 0.05769231   0.01923077
## prize   0.0000000 3.00000000 3.00000000 3.00000000 5.00000000  20.00000000
## payout -2.0000000 1.00000000 1.00000000 1.00000000 3.00000000  18.00000000

Problem 6-A

number <- mat[1, 1]
face <- mat[1, 2] + mat[1, 3] + mat[1, 4]
ace <- mat[1, 5]
ace_club <- mat[1,6]
(number * - 2) + (face * 1) + (ace * 3) + (ace_club * 18)
## [1] -0.4807692

Problem 6-B

No, this is not a good way for Andy to make money as he can expect to lose $0.4807692 each game.

Problem 7

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

Problem 7-A

# Amount of ice cream served at party
mymat3[1, 1] + (3 * mymat3[2, 1])
## [1] 54
#Standard Deviation
sqrt(mymat3[1, 3] + (3 * mymat3[2,3]))
## [1] 1.089725

Problem 7-B

# Amount of ice cream left after scooping out one serve
mymat3[1, 1] - mymat3[2, 1]
## [1] 46
# Standard Deviation
sqrt(mymat3[1, 3] + mymat3[2, 3])
## [1] 1.030776

Problem 7-C

The variance of two independent variables will increase whether we add or subtract because the likelihood of the variance increases in relation to the other variable.