Suppose you have a deck with only three cards. Each card has two sides, and each side is either black or white. One card has two black sides. The second card has one black and one white side. The third card has two white sides. Now suppose all three cards are placed in a bag and shuffled. Someone reaches into the bag and pulls out a card and places it flat on a table. A black side is shown facing up, but you don’t know the color of the side facing down. Show that the probability that the other side is also black is 2/3. Use the counting method (Section 2 of the chapter) to approach this problem. This means counting up the ways that each card could produce the observed data (a black side facing up on the table).
Solution: Directly
With given cards and their sides (BB, BW, WW) there are 3 possibilities how to see black side on top: 3B of 6 (BB, BB, BW).
Two of these options have also black facing down (BB, BB), this gives 2 options out of 3 possibilities, i.e. 2/3 probability.
Also demonstrated with counting:
# BW means B on top, W downd <-crossing(card =c("BB", "BW", "WW"), top_side =1:2)d <- d %>%mutate(# is the top face black?top_black =if_else(card =="BB"| (card =="BW"& top_side ==1), T, F),# is the bottom face black? (irrespective of the top)bottom_black =if_else(card =="BB"| (card =="BW"& top_side ==2), T, F) )d
d %>%filter(top_black) %>%summarise(p =mean(bottom_black))
# A tibble: 1 × 1
p
<dbl>
1 0.667
Solution: Likelihood
This may be convenient in homeworks with extra limitations (some card or face is heavier, more common etc.).
# how many ways a card can yield black on top?card_bb_likelihood <-2card_bw_likelihood <-1card_ww_likelihood <-0# remember the order: BB, BW, WWlikelihood <-c(card_bb_likelihood, card_bw_likelihood, card_ww_likelihood)prior <-c(1, 1, 1)posterior <- prior * likelihood# now normalize to probabilityposterior <- posterior /sum(posterior)# the first card is BB, the only option with BB facing also downposterior[1]