Skip to content

Instantly share code, notes, and snippets.

@toyeiei
Last active Jan 21, 2019
Embed
What would you like to do?
simple bayes
# get 15 head from 20 draws - fair coin
p_H15_fair <- dbinom(15, 20, prob = 0.50)
# get 15 head from 20 draws - biased coin
p_H15_biased <- dbinom(15, 20, prob = 0.75)
# subjective probability about the coin
p_fair <- 0.4
p_biased <- 1 - p_fair
# bayes theorem
p_fair_H15 <- p_H15_fair * p_fair / (p_H15_fair * p_fair + p_H15_biased * p_biased)
print(p_fair_H15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment