Skip to content

Instantly share code, notes, and snippets.

@toyeiei
Last active January 28, 2019 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toyeiei/24f97d2747c637eda2c578ca47b835ed to your computer and use it in GitHub Desktop.
Save toyeiei/24f97d2747c637eda2c578ca47b835ed to your computer and use it in GitHub Desktop.
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