#FERTIG
bayes <- function(pa, p_bBa, p_bBak) {
z <- paste0("P(","A\u035E","|B)")
vars <- c(pa,p_bBa,p_bBak)
if(missing(vars)) {
res <- paste0(
"Zur Berechnung der Bedingten Wahrscheinlichkeit bitte P(A), P(B|A) und ",z, " angeben."
)
} else {
p_ak <- 1-pa
pb <- pa * p_bBa + p_ak * p_bBak
p_anb <- pa * p_bBa
p_aBb <- p_anb/pb
res <- c(
noquote(
paste(
"\n",
"Totale Wahrscheinlichkeit P(B) =",round(pb,4), "\n",
"Bayes Theorem P(A|B) =",round(p_aBb,4),"\n",
"Gegenwahrscheinlichkeit Bayes", z,"=",round(1-p_aBb,4), "\n",
"In Worten: Die Wahrscheinlichkeit für P(A|B) beträgt", round(p_aBb,4)
)
)
)
}
return(cat(res))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.