PROJECTENGRAM

BAYES'S FORMULA

Tags: #◇Computer Science #◇STT101A #◇Conceptual #◇Bayes's Formula #◇Probability #◇Statistics


◇Overview

Bayes' Formula (Bayes' Theorem) provides the mathematical mechanism for updating conditional probabilities in light of new observed evidence. It connects the prior probability of an underlying cause with the posterior probability after an observable consequence occurs, formalizing rational Bayesian inference across machine learning, cybersecurity threat detection, and statistical modeling.

◇Key Definitions

  • Prior Probability (P(Bj)P(B_j)): The initial probability of hypothesis or state BjB_j before observing new evidence.
  • Likelihood (P(A∣Bj)P(A \mid B_j)): The conditional probability that evidence AA is observed, assuming hypothesis BjB_j is true.
  • Marginal Probability / Evidence (P(A)P(A)): The total probability of observing evidence AA across all mutually exclusive scenarios in the sample space.
  • Posterior Probability (P(Bj∣A)P(B_j \mid A)): The updated probability of hypothesis BjB_j given that evidence AA has actually occurred.
  • Partition of Sample Space: A collection of mutually exclusive and collectively exhaustive events {B1,B2,…,Bk}\{B_1, B_2, \dots, B_k\} such that Bi∩Bj=∅B_i \cap B_j = \emptyset for i≠ji \ne j, and ⋃i=1kBi=S\bigcup_{i=1}^k B_i = S.

◇Theoretical Framework: Derivation & Mathematical Formulation

The Law of Total Probability

For any event AA and a partition {B1,B2,…,Bk}\{B_1, B_2, \dots, B_k\} of sample space SS:
P(A)=∑i=1kP(A∩Bi)=∑i=1kP(A∣Bi)P(Bi)P(A) = \sum_{i=1}^k P(A \cap B_i) = \sum_{i=1}^k P(A \mid B_i) P(B_i)

Bayes' Theorem

By the definition of conditional probability:
P(Bj∣A)=P(Bj∩A)P(A)P(B_j \mid A) = \frac{P(B_j \cap A)}{P(A)}
Substituting the multiplication rule P(Bj∩A)=P(A∣Bj)P(Bj)P(B_j \cap A) = P(A \mid B_j) P(B_j) into the numerator and the Law of Total Probability into the denominator yields:
P(Bj∣A)=P(A∣Bj)P(Bj)∑i=1kP(A∣Bi)P(Bi)P(B_j \mid A) = \frac{P(A \mid B_j) P(B_j)}{\sum_{i=1}^k P(A \mid B_i) P(B_i)}

Probability Tree Model


◇Stepped Numerical Walkthrough: The Base Rate Fallacy in Threat Detection

Scenario: An enterprise Intrusion Detection System (IDS) monitors encrypted network flows for a rare zero-day rootkit.

  • Base Rate (Prior Prevalence): Only 0.5%0.5\% of network flows contain the rootkit: P(R)=0.005P(R) = 0.005, so benign traffic is P(Rc)=0.995P(R^c) = 0.995.
  • True Positive Rate (Sensitivity): If traffic contains the rootkit, the IDS raises an alert with 99%99\% probability: P(+∣R)=0.99P(+ \mid R) = 0.99.
  • False Positive Rate: If traffic is benign, the IDS falsely triggers with 2%2\% probability: P(+∣Rc)=0.02P(+ \mid R^c) = 0.02.

Objective: If an incoming packet flow triggers an IDS alarm (++), calculate the posterior probability that the packet actually carries the malicious rootkit (P(R∣+)P(R \mid +)).

Step 1: Compute Total Probability of an Alarm (P(+)P(+))

Using the Law of Total Probability:
P(+)=P(+∣R)P(R)+P(+∣Rc)P(Rc)P(+) = P(+ \mid R)P(R) + P(+ \mid R^c)P(R^c)
Substitute the known values:
P(+)=(0.99×0.005)+(0.02×0.995)P(+) = (0.99 \times 0.005) + (0.02 \times 0.995)
P(+)=0.00495+0.01990=0.02485P(+) = 0.00495 + 0.01990 = \mathbf{0.02485}
Observation: Notice that false alarms (0.019900.01990) outnumber true alarms (0.004950.00495) by a factor of 4!

Step 2: Apply Bayes' Formula

P(R∣+)=P(+∣R)P(R)P(+)=0.004950.02485≈0.1992(19.92%)P(R \mid +) = \frac{P(+ \mid R)P(R)}{P(+)} = \frac{0.00495}{0.02485} \approx \mathbf{0.1992} \quad (19.92\%)

Step 3: Analytical Insight

Despite an impressive 99%99\% detection sensitivity and a low 2%2\% false positive rate, an alarm only indicates a ≈19.92%\approx 19.92\% chance of an actual breach.
This counterintuitive result is known as the Base Rate Fallacy: because benign traffic is overwhelmingly more common (99.5%99.5\%) than malicious traffic (0.5%0.5\%), the sheer volume of benign opportunities generates four times more false positives than true positives.


◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

In Bayes' Theorem, what does the term P(A∣B)P(A \mid B) represent?

Q2

What role does the Law of Total Probability play in Bayes' Formula?

Q3

Why does the Base Rate Fallacy occur in medical screening or intrusion detection?

Q4

If events B1,B2,B3B_1, B_2, B_3 form a partition of sample space SS, which condition must strictly hold?

Q5

In our IDS example, what was the probability that a randomly chosen flow triggered an alarm (P(+)P(+))?

Q6

If the prior probability of hypothesis BB is 0.100.10, likelihood P(A∣B)=0.80P(A \mid B) = 0.80, and total evidence probability P(A)=0.20P(A) = 0.20, what is the posterior P(B∣A)P(B \mid A)?

Q7

What happens to the posterior probability P(B∣A)P(B \mid A) if the prior probability P(B)→0P(B) \to 0 while likelihood and evidence remain non-zero?

Q8

In Bayesian statistics, how is sequential updating performed when a second independent piece of evidence A2A_2 arrives?

Q9

What does a likelihood ratio of P(A∣B)/P(A∣Bc)>1P(A \mid B) / P(A \mid B^c) > 1 indicate?

Q10

Which branch of artificial intelligence directly implements Bayes' Formula with conditional independence assumptions between features?