Salta al contenuto
Note per Studenti Law of Total Probability and Bayes' Rule Report

Law of Total Probability and Bayes' Rule

In questa pagina 3

Law of total probability

Let E,F∈FE,F\in\mathcal F with P(F)>0P(F)>0. Recalling the disjoint decomposition E=(E∩F)∪(E∩Fc)E=(E\cap F)\cup(E\cap F^c) (Sample Spaces and EventsThe sample space collects all possible outcomes of an experiment, events are its subsets, and set operations (complement, union, intersection, difference, partitions) translate into statements about what occurs.Sample Spaces and Events →) and the multiplication formulas (Conditional ProbabilityThe conditional probability P(E|F) = P(E and F)/P(F) updates the probability of E after learning that F occurred; it is itself a probability measure and yields the multiplication formula for intersections.Conditional Probability →): P(E)=P(E∩F)+P(E∩Fc)=P(E∣F)P(F)+P(E∣Fc)P(Fc)P(E)=P(E\cap F)+P(E\cap F^c)=P(E\mid F)P(F)+P(E\mid F^c)P(F^c) (valid for 0<P(F)<10<P(F)<1, so that both conditional probabilities exist).

Example (continuation of the urn with 80 black and 20 red balls). P([d2=red])=P([d2=red]∣[d1=red])P([d1=red])+P([d2=red]∣[d1=black])P([d1=black])=1999⋅20100+2099⋅80100=20100.P([d_2=\text{red}])=P([d_2=\text{red}]\mid[d_1=\text{red}])P([d_1=\text{red}])+P([d_2=\text{red}]\mid[d_1=\text{black}])P([d_1=\text{black}])=\frac{19}{99}\cdot\frac{20}{100}+\frac{20}{99}\cdot\frac{80}{100}=\frac{20}{100}.

Generalization. If (Fi)i=1n(F_i)_{i=1}^n is a partition of Ω\Omega with P(Fi)>0P(F_i)>0 for all ii, then P(E)=P(E∩Ω)=P(E∩⋃iFi)=P(⋃i(E∩Fi))=∑i=1nP(E∩Fi)=∑i=1nP(E∣Fi)P(Fi).P(E)=P(E\cap\Omega)=P\Big(E\cap\bigcup_iF_i\Big)=P\Big(\bigcup_i(E\cap F_i)\Big)=\sum_{i=1}^nP(E\cap F_i)=\sum_{i=1}^nP(E\mid F_i)P(F_i). The events (E∩Fi)(E\cap F_i) are disjoint since (Fi)(F_i) is a partition; this identity is the law of total probability, valid if (Fi)(F_i) is a partition of Ω\Omega. It is typical of applications in which the data of the problem are the P(E∣Fi)P(E\mid F_i) and the P(Fi)P(F_i) for i=1,…,ni=1,\dots,n.

Example (memory chips). A company produces PCs assembling components bought from several vendors. The memory chips come from 3 vendors A,B,CA,B,C in proportions 25%,25%,50%25\%,25\%,50\%. Chips of vendor AA are defective in 2%2\% of cases, those of BB in 3%3\%, those of CC in 4%4\%. The chips are kept together in a common bin and a chip is picked randomly from the bin. Probability that the chip picked is defective? (Recall that a percentage is an empirical probability.) Data: P(A)=0.25, P(B)=0.25, P(C)=0.50,P(D∣A)=0.02, P(D∣B)=0.03, P(D∣C)=0.04,P(A)=0.25,\ P(B)=0.25,\ P(C)=0.50,\qquad P(D\mid A)=0.02,\ P(D\mid B)=0.03,\ P(D\mid C)=0.04, where D≜D\triangleq "chip is defective" and P(A)P(A) is the probability that the chip comes from AA. By the law of total probability: P(D)=P(D∣A)P(A)+P(D∣B)P(B)+P(D∣C)P(C)=0.02×0.25+0.03×0.25+0.04×0.5=0.005+0.0075+0.02=0.0325=3.25%.P(D)=P(D\mid A)P(A)+P(D\mid B)P(B)+P(D\mid C)P(C)=0.02\times0.25+0.03\times0.25+0.04\times0.5=0.005+0.0075+0.02=0.0325=3.25\%.

Bayes' rule

This is possibly the single most important result of the first six introductory lectures. The mathematics behind the rule is elementary; the examples clarify its importance.

Lemma (Bayes' rule). Let (Fi)i=1n(F_i)_{i=1}^n be a partition of Ω\Omega with P(Fi)>0P(F_i)>0 for all ii. Then for any E∈FE\in\mathcal F (with P(E)>0P(E)>0) and for all j=1,…,nj=1,\dots,n, P(Fj∣E)=P(Fj∩E)P(E)=P(E∣Fj)P(Fj)∑i=1nP(E∣Fi)P(Fi),P(F_j\mid E)=\frac{P(F_j\cap E)}{P(E)}=\frac{P(E\mid F_j)P(F_j)}{\sum_{i=1}^nP(E\mid F_i)P(F_i)}, where the numerator uses the multiplication rule and the denominator the law of total probability.

Terminology.

  • P(Fj)P(F_j): given a-priori probabilitiesprobabilities assigned before observing E;
  • P(E∣Fj)P(E\mid F_j): given conditional probabilities;
  • P(Fj∣E)P(F_j\mid E): posterior probabilities, computed on the basis of the data and the observation of the occurrence of EE. They are interesting because they tell how the a-priori probabilities change after observing EE.

Example: diagnostic tests

Diagnostic tests are quick, cheap procedures to evaluate the presence of a critical condition (in medicine: disease or no disease; in engineering: signal or no signal; etc.). The test is subject to errors: it can be positive when the condition is not present and negative when the condition is present. Properly interpreted it is nevertheless very useful in managing uncertainty. Notation: D+D_+ condition present, D−D_- condition absent, T+T_+ test positive, T−T_- test negative. The 2×22\times2 table of outcomes:

D+D_+ D−D_-
T+T_+ true positive false positive
T−T_- false negative true negative

and the table of conditional probabilities:

D+D_+ D−D_-
T+T_+ P(T+∣D+)P(T_+\mid D_+) = sensibility P(T+∣D−)P(T_+\mid D_-) = false positive
T−T_- P(T−∣D+)P(T_-\mid D_+) = false negative P(T−∣D−)P(T_-\mid D_-) = specificity

Ideally P(T+∣D+)=1P(T_+\mid D_+)=1 and P(T−∣D−)=1P(T_-\mid D_-)=1; in reality P(T+∣D+)=α<1P(T_+\mid D_+)=\alpha<1 and P(T−∣D−)=β<1P(T_-\mid D_-)=\beta<1. Commercial tests declare their sensibility α\alpha and specificity β\beta. To use the test one also needs the a-priori probability P(D+)P(D_+).

Numerical example. Suppose α=P(T+∣D+)=0.99\alpha=P(T_+\mid D_+)=0.99, β=P(T−∣D−)=0.98\beta=P(T_-\mid D_-)=0.98 and P(D+)=0.0002P(D_+)=0.0002 (empirical observations show that the condition affects 2 per 10,000 individuals in the general population). You take the test and it turns out positive: T+T_+ has occurred. The rational reaction is to compute the posterior probability with Bayes' rule: after observing T+T_+ you do not belong anymore to the general population but to the population that tested positive. P(D+∣T+)=P(T+∣D+)P(D+)P(T+)=P(T+∣D+)P(D+)P(T+∣D+)P(D+)+P(T+∣D−)P(D−)=0.99⋅0.00020.99⋅0.0002+(1−0.98)(1−0.0002)≈0.01.P(D_+\mid T_+)=\frac{P(T_+\mid D_+)P(D_+)}{P(T_+)}=\frac{P(T_+\mid D_+)P(D_+)}{P(T_+\mid D_+)P(D_+)+P(T_+\mid D_-)P(D_-)}=\frac{0.99\cdot0.0002}{0.99\cdot0.0002+(1-0.98)(1-0.0002)}\approx0.01. The a-priori probability P(D+)=0.0002P(D_+)=0.0002 has increased 50 times after the positive test, reaching P(D+∣T+)=0.01P(D_+\mid T_+)=0.01, but it is still rather small. A complete examination to determine whether the condition D+D_+ is actually present is advisable but not urgent.

(Here P(T+∣D−)=1−P(T−∣D−)=1−βP(T_+\mid D_-)=1-P(T_-\mid D_-)=1-\beta by the complement property of conditional probability.)

Versione ripasso

  • Law of total probability: (Fi)i=1n(F_i)_{i=1}^n partition of Ω\Omega, P(Fi)>0P(F_i)>0: P(E)=∑i=1nP(E∣Fi)P(Fi);two events: P(E)=P(E∣F)P(F)+P(E∣Fc)P(Fc).P(E)=\sum_{i=1}^nP(E\mid F_i)P(F_i);\qquad\text{two events: }P(E)=P(E\mid F)P(F)+P(E\mid F^c)P(F^c). Proof: E=⋃i(E∩Fi)E=\bigcup_i(E\cap F_i) disjoint, then multiplication formula.
  • Bayes' rule: P(Fj∣E)=P(E∣Fj)P(Fj)∑iP(E∣Fi)P(Fi).P(F_j\mid E)=\frac{P(E\mid F_j)P(F_j)}{\sum_iP(E\mid F_i)P(F_i)}. P(Fj)P(F_j) a-priori, P(E∣Fj)P(E\mid F_j) given conditional, P(Fj∣E)P(F_j\mid E) posterior.
  • Chips: P(D)=0.02⋅0.25+0.03⋅0.25+0.04⋅0.5=3.25%P(D)=0.02\cdot0.25+0.03\cdot0.25+0.04\cdot0.5=3.25\%.
  • Diagnostic test: sensibility α=P(T+∣D+)\alpha=P(T_+\mid D_+), specificity β=P(T−∣D−)\beta=P(T_-\mid D_-); with α=0.99\alpha=0.99, β=0.98\beta=0.98, P(D+)=0.0002P(D_+)=0.0002: P(D+∣T+)≈0.01P(D_+\mid T_+)\approx0.01 (50 times the prior but still small).
  • Typical mistakes: confusing P(D+∣T+)P(D_+\mid T_+) with P(T+∣D+)P(T_+\mid D_+); ignoring the prior P(D+)P(D_+); applying the law on events that are not a partition.

Teoria collegata