Homework chapter 2


2E1. Expression number (2) is correct.


2E2. Statement (3) is correct.


2E3. There are two correct expressions, (1) and (4).


2E4. Probabilities can change when we get updated information or data. The probability is therefore not necessarily an objective truth, but it is there to help the observer make sense of the world. The probability of water on Earth can change depending on available information.


2M1.

# define grid
p_grid <- seq(from = 0, to = 1, length.out = 10)
# define prior
prior <- rep(1,10)
# compute likelihood of each value in grid
likelihood <- dbinom(3, size = 3, prob = p_grid)
# compute product of likelihood and prior
unstd.posterior <- likelihood*prior
# standardize the posterior, so it sums to 1
posterior <- unstd.posterior / sum(unstd.posterior)

Plot grid approximate posterior distribution for observation W W W:

plot(p_grid, posterior, type = "b",
     xlab = "probability of water", ylab = "posterior probability")
mtext("W W W")

Now we do the same for observation W W W L, and all we have to change is the likelihood:

likelihood <- dbinom(3, size = 4, prob = p_grid)

This is the posterior distribution for observation W W W L:

And we do the same for the final observation, L W W L W W W

likelihood <- dbinom(5, size = 7, prob = p_grid)

We see that with every update, and observation of W, the height of the plausibility curve increases, and shifts to the right (larger values of p). If we had more observations of L, the curve would shift towards the left (smaller values of p).



2M4.

Ways each card could produce observation B, using the counting approach:
WW –> 0
BW –> 1
BB –> 2


possible observations: first side black - second side black

b1-b2: 1 - 1
b2-b1: 1 - 1
b1-w1: 1 - 0
w1-b1: 0 - 0
w1-w2: 0 - 0
w2-w1: 0 - 0


If we sum the ways the first side is black we get 3. There are only two ways the second side could be black when the first card is black. So the probability that the second side is black given that the first side was black is 2/3.




2M5. We can use the same logic with the counting approach here, we just add another card (BB). We can list all possible outcomes and then count the number of ways the first side is black, which is 5. There are 4 ways the 2nd side is black. So the Pr that the second side is black given that the first side was black is 4/5.

2M6.

Same here, but now we add several more possible outcomes based on the new information.

possible observations: first side black - second side black

b1-b2: 1 - 1
b2-b1: 1 - 1
b1-w1: 1 - 0
w1-b1: 0 - 0
b1-w1: 1 - 0
w1-b1: 0 - 0
w1-w2: 0 - 0
w2-w1: 0 - 0
w1-w2: 0 - 0
w2-w1: 0 - 0
w1-w2: 0 - 0
w2-w1: 0 - 0

There are 4 ways the first card is black, and 2 ways the second card is also black. So 4/2, or 0.5.