Nothing
knitr::opts_chunk$set(fig.width=6, fig.height=4, fig.path='Figs/', echo=TRUE, warning=FALSE, message=FALSE)
Here is a standard sampling-without-replacement problem. Suppose we have $N$ balls in a box, $B$ that are black and the remaining $W = N - B$ balls are white.
You sample $n$ balls from the box and $b$ turn out to be black. What have you learned about the number $B$ that are black in the box?
This is a Bayes' rule problem. We'll illustrate it for the case where $N = 50$.
library(TeachBayes) bayes_df <- data.frame(B=0:50, Prior=rep(1/51, 51))
dsampling()
.sample_b <- 3 pop_N <- 50 sample_n <- 10 bayes_df$Likelihood <- dsampling(sample_b, pop_N, bayes_df$B, sample_n)
bayesian_crank()
function and obtain the posterior probabilities for $B$.bayes_df <- bayesian_crank(bayes_df)
I compare the prior and posterior probabilities for $B$ graphically.
prior_post_plot(bayes_df)
Here is a 90 percent probability interval for $B$:
library(dplyr) discint(select(bayes_df, B, Posterior), 0.90)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.