Skip to content

Instantly share code, notes, and snippets.

@carlislerainey
Created November 12, 2014 18:08
Show Gist options
  • Save carlislerainey/75a0d10711e7653bc451 to your computer and use it in GitHub Desktop.
Save carlislerainey/75a0d10711e7653bc451 to your computer and use it in GitHub Desktop.
Illustrate the idea of a prior distribution.
n <- 0
k <- 0
a <- c(1, 2, 3, 4, 5)
b <- c(1, 2, 3, 4, 5)
col <- 1:length(a)
names <- c("Carlisle", "B", "C", "D", "E")
plot(NULL, xlim = c(0, 1), ylim = c(0, 3),
xlab = expression(pi),
ylab = "Density")
for (i in 1:length(a)) {
pi <- seq(0, 1, by = 0.01)
post <- dbeta(pi, a[i] + k, b[i] + n - k)
lines(pi, post, col = i)
}
legend(legend = names, lty = 1, col = col,
x = par("usr")[2], xjust = 1,
y = par("usr")[4], yjust = 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment