Confidence/credible interval applet

Written by Paul O. Lewis (23-Mar-2020). See notes below the plot.

Illustrates the difference between a frequentist confidence interval and a Bayesian credible interval for a coin-flipping experiment.

In confidence interval mode, change the true value of theta (expected fraction of heads) using the mouse and see the expected distribution of estimated proportion of heads change. The confidence interval comprises the set of all theta values for which the original estimated proportion of heads (dotted vertical line) is not surprising (i.e. somewhere in the black region of the histogram).

In credible interval mode, change the “water level” by dragging the horizontal line using your mouse. This defines a highest posterior density (HPD) credible interval with the indicated posterior probability. The MLE of the proportion of heads is shown as a vertical dotted line, even though the MLE has no role in the construction of a Bayesian credible interval. Note how the Beta prior affects the posterior, which in turn affects the credible interval.

Acknowledgements

This applet makes use of the excellent d3js javascript library. Please see the GitHub site for details about licensing of other libraries that may have been used in the source code for this applet.

Licence

Creative Commons Attribution 4.0 International. License (CC BY 4.0). To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.