Created
November 12, 2014 18:08
-
-
Save carlislerainey/75a0d10711e7653bc451 to your computer and use it in GitHub Desktop.
Illustrate the idea of a prior distribution.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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