Skip to content

Instantly share code, notes, and snippets.

@toyeiei
Created Jan 30, 2019
Embed
What would you like to do?
# create a prior probability vector
prior <- 0:10 * 0.1
# writing what we know
beta <- 0.20
alpha <- 0.05
power <- 1 - beta
# bayes theorem
posterior <- power * prior / (power * prior + alpha * (1-prior))
round(posterior, 2)
# plot posterior
plot(prior, posterior, pch = 16, type = "b")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment