P_B_A <- 0.904
P_A <- 1 / 18000
P_B_notA <- 0.065
P_notA <- 1 - P_A

Solution

P_B <- (P_B_A * P_A) + (P_B_notA * P_notA)
P_B
## [1] 0.06504661
P_A_B <- (P_B_A * P_A) / P_B
P_A_B
## [1] 0.0007720959
P_Alert_PONFL <- 0.904
P_Alert_NonPONFL <- 0.065
P_PONFL <- 1 / 18000
P_NonPONFL <- 1 - P_PONFL

#total probability of an alert
P_Alert <- (P_Alert_PONFL * P_PONFL) + (P_Alert_NonPONFL * P_NonPONFL)

# posterior probability of being a PONFL with alert
P_PONFL_Alert <- (P_Alert_PONFL * P_PONFL) / P_Alert

#  result
P_PONFL_Alert
## [1] 0.0007720959

Calculate the total probability of an alert

\[ \begin{equation} \label{eq:bayes} [P(Alert) = P(Alert|PONFL) \cdotP(PONFL)+P(Alert|Non-PONFL) \cdot P(Non-PONFL) ] \end{equation} \] # Calculate the posterior probability of being a PONFL given an alert

\[ \begin{equation} \label{eq:bayes} [P(PONFL|Alert) =\frac{P(Alert|PONFL \cdot P(PONFL)}{P(Alert)} ] \end{equation} \]