= Solution
In <Markov chain Monte Carlo>, retain the derived quantity $\delta=p_M-p_T$ at every iteration. Rough <BUGS> code using the actual observations is
``
model {
pM ~ dbeta(0.5,0.5)
pT ~ dbeta(0.5,0.5)
milkAnswers ~ dbin(pM,4)
teaAnswers ~ dbin(pT,4)
delta <- pM-pT
positive <- step(delta)
}
``
Supply `milkAnswers=3` and `teaAnswers=1`. Summarize `delta` by its <posterior mean>, empirical <quantiles> and <credible interval>; the average of `positive` estimates $\mathbb P(p_M>p_T\mid\mathcal D)$. Here \b[$\mathbb E[\delta\mid\mathcal D]=0.4$]. Check <Markov chain Monte Carlo convergence diagnostics> before interpreting the simulation. Since both <Bayesian posteriors> are independent known <Beta distributions>, direct independent sampling is an equally valid, simpler way to obtain the same summaries.
Back to article page