The last line of slide 61 (https://speakerdeck.com/rmcelreath/statistical-rethinking-2022-lecture-02?slide=61) and in the book R code 3.2 (and R code 2.3) uses a standardization rule different from the one used for prior probability.
As explained by the Overthinking box at page 35 of the book, prior is an array of ones, since the important property is that it integrates to one over p_grid. The sum of the values of prior is indeed much greater than 1 (20 in code 2.3, 1000 in code 3.2).
The standardization used for posterior instead guarantees that sum(posterior) == 1, while the integral over p_grid is less than one.
This is not relevant for the shape of the posterior curve, but the asymmetry bothers me. I believe the right statement to use in 3.2 is
posterior <- (posterior / sum(posterior))*length(posterior)
then sum(posterior) == sum(prior) and both their integrals over p_grid should be 1.
The last line of slide 61 (https://speakerdeck.com/rmcelreath/statistical-rethinking-2022-lecture-02?slide=61) and in the book R code 3.2 (and R code 2.3) uses a standardization rule different from the one used for prior probability.
As explained by the Overthinking box at page 35 of the book,
prioris an array of ones, since the important property is that it integrates to one overp_grid. The sum of the values ofprioris indeed much greater than 1 (20 in code 2.3, 1000 in code 3.2).The standardization used for
posteriorinstead guarantees thatsum(posterior) == 1, while the integral overp_gridis less than one.This is not relevant for the shape of the posterior curve, but the asymmetry bothers me. I believe the right statement to use in 3.2 is
then
sum(posterior) == sum(prior)and both their integrals overp_gridshould be 1.