Introduction to Bayes using Discrete Priors
Jim Albert
May 28, 2014
Learning About a Proportion
A Discrete Prior
Consider a population of “successes” and “failures” where the proportion of suc-cesses is p. Suppose p
takes on the discrete set of values 0, .01, ..., .99, 1 and one assigns a uniform prior on these values. We enter the values of p and the associated probabilities into the vectors p and prior, respectively.
p <- seq(0, 1, by = 0.01)
prior <- 1 / 101 + 0 * p #为什么用0×p,自己好好想想,试试
plot(p, prior, type="h", main="Prior Distribution")
Posterior Distribution
Suppose one takes a random sample from the population without replacement
and observes 20 successes and 1