Skip to content

Instantly share code, notes, and snippets.

@toyeiei

toyeiei/.R

Last active Jan 28, 2019
Embed
What would you like to do?
bayes example
# what we know
p_pos_cancer <- 0.99
p_cancer <- 0.01
p_not_cancer <- 1 - 0.01
p_pos_not_cancer <- 0.05
# bayes theorem
p_cancer_pos <- (p_pos_cancer*p_cancer) / (p_pos_cancer*p_cancer + p_pos_not_cancer*p_not_cancer)
print(p_cancer_pos) # 0.1667
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment