mybayes = function( ppgu, pngnu,pu=0.005) # pu = prob user, ppgu = prob pos g user (sensitivity), pngnu = prob neg g not user
{
pnu=1-pu # pu is the prior, pnu = prob not user
pngu = 1-ppgu # pngu = prob neg given user
ppgnu = 1-pngnu # ppgnu = prob pos given not user
pp = pu*ppgu + pnu*ppgnu # pp = prob pos = evidence
pugp = pu*ppgu/pp # pugp = prob user g pos
pnugp=1-pugp # pnugp = prob not user g pos
list("post" = pugp,pnugp=pnugp, prior=pu, sensitivity = ppgu, specificity = pngnu)
}
mybayes(.99,.97,0.2/100)
obj=mybayes(0.99,0.99,seq(0.001, 0.005, length=1000))
hist(obj$post,freq = FALSE)
windows()
curve(mybayes(0.99,x,0.005)[["post"]], xlim = c(0.97,1))
curve(mybayes(0.99,0.99,x)$post, xlim = c(0.001,0.05))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.