Created
August 10, 2016 15:41
-
-
Save richarddmorey/eb1dc700941e3b6fa1b480c669fe3e35 to your computer and use it in GitHub Desktop.
example, Essex, beta/binomial
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
y = 13 | |
N = 35 | |
a = 1 | |
b = 1 | |
theta = seq(0, 1, len = 100) | |
likelihood = theta ^ y * (1-theta)^(N-y) #dbinom(y, N, theta) | |
prior = theta ^ (a-1) * (1-theta)^(b-1) #dbeta(theta, a, b) | |
posterior1 = prior * likelihood | |
posterior2 = dbeta(theta, y + a, N - y + b) | |
plot(theta, likelihood, ty='l') | |
abline(v = y/N, col="red") | |
plot(theta, prior, ty='l') | |
plot(theta, posterior1, ty='l') | |
plot(theta, posterior2, ty='l', col="blue") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment