Understanding a little bit about Posterior Probability
$$ \text{Pr}(p|W,N)=\frac{\text{Pr}(W|N,p)\text{Pr}(p)}{\sum\text{Pr}(W|N,p)\text{Pr}(p)\forall p} $$ $$ \text{Posterior}=\frac{(\text{Prob. observed variables}\times(\text{Prior})}{\text{Normalising constant}} $$
(Where the normalising constant standardises it). The probability of observed variables is also called the "likelihood".
Calculating posterior:
- analytical approach (often impossible)
- Grid approximation (very intensive)
- Quadratic approximation (limited) (A.K.A. Lacrosse approximation)
- Markov chain monte carlo (intensive)
Here is some example R code to do such a thing:
# dbinom(6, size=9, prob=0.5)
p_grid <- seq(from=0, to=1, length.out=1000)
prob_p <- rep(1, 1000)
prob_data <- dbinom(6, size=9, prob=p_grid)
posterior <- prob_data * prob_p
posterior <- posterior / sum(posterior) # standardise it