Created
July 11, 2019 11:51
-
-
Save Harshit1694/1775867933427b49c6902a7cb9c98836 to your computer and use it in GitHub Desktop.
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
#Bayes Theorem | |
cancer <- sample(c('No','Yes'), size=1000, replace=TRUE, prob=c(0.99852,0.00148)) | |
test <- rep(NA, 1000) # creating a dummy variable | |
test[cancer=='No'] <- sample(c('Negative','Positive'), size=sum(cancer=='No'), replace=TRUE, prob=c(0.99,0.01)) | |
test[cancer=='Yes'] <- sample(c('Negative','Positive'), size=sum(cancer=='Yes'), replace=TRUE, prob=c(0.07, 0.93)) | |
P_cancer_and_pos<-0.00148*0.93 | |
P_no_cancer_and_pos<-0.99852*0.01 | |
Bayes_Theorem<-(P_cancer_and_pos/(P_cancer_and_pos+P_no_cancer_and_pos)) | |
Bayes_Theorem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment