ELEC 321

# Conditional Probability

Updated 2017-09-28

## Conditional Probability

The outcome could be any element in the sample space $\Omega$, but the range of possibilities is restricted due to partial information.

Partial Information: Insufficient or fuzzy information about the output

Example: examples of partial information

• The roll of the dice is at least a 4
• The final grade for ELEC 321 is at least 75%

Conditioning Event: The event $B$ that represents partial information. The event of interest is denoted by $A$

Example: rolling a dice with conditional event and event of interest

$B=\{4,5,6\}=\{\text{rolls at least a 4}\}$ (conditioning event)

$A=\{6\}=\{\text{rolls a 6}\}$ (event of interest)

Example: the final grade of ELEC 321

$B=[75,100]=\{\text{at least 75%}\}$ (conditioning event)

$A=[90, 100]=\{\text{ace the course (get 90% to 100%)}\}$ (event of interest)

### Definition of Conditional Probability

Suppose that the probability of $B$ is not 0: $\mathbb P(B)\gt 0$, then,

This reads “the probability of $A$ given $B$ equals to the probability of $A$ and $B$ divided by the probability of $B$.

Rearrange and we get useful formulas:

### Conditional Probability and Probability Axioms

$\mathbb P(A\vert B)$ is a function of $A$ and for fixed $B$ (otherwise the axioms doesn’t hold) satisfies all of the probability axioms listed in module 1.

1. If $\{A_i\}$ are disjoint for $1\leq i\leq n$ then:

Example: dice roll from above (and assuming each side of the dice is equally likely)

We suppose that $\mathbb P(\text{grade is larger than } x) = \frac{100-x}{100}$ (each percentage is equally likely).

## Screening Tests

Consider a screening test for defective iPhones, the screening test can either result in:

• Positive (iPhone has defect)
• Negative (iPhone has no defect)

But screening test itself sometimes have two types of errors:

• False positive (test is defective, iPhone might not be defect)
• False negative (test is not defective, iPhone has defect)

Given these outcomes, there are total of 4 possible events for each event:

For iPhone status:

For test result:

In this scenario, we will arbitrarily define the sensitivity (probability of test positive given that the iPhone is defective) of the test to be 0.95. Which also implies that the probability of test negative given a defective iPhone is $\mathbb P(B^c\vert D)=1-0.95=0.05$.

We will also arbitrarily define the specificity (probability of test negative given that the iPhone is not defective) of the test to be 0.99. Similarly, the probability that the test is positive if the device is not defective is $\mathbb P(B\vert D^c)=1-0.99=0.01$.

The proportion of the the defective items is also known.

Given the conditions, we can compute:

• Probability that a randomly chosen iPhone tests positive

• Probability of defective given that the test resulted positive

• Probability of defective given that the test resulted negative

• Probability of screening error

## Bayes’ Theorem

Bayes’ theorem is a formula that describes how to update the probability of hypothesis given some evidence.

Where $H$ is hypothesis, $E$ is the evidence.

• $\mathbb P(H)$ is the Prior Probability
• $\mathbb P(H\vert E)$ is the Posterior Probability
• $\frac{\mathbb P(H)}{\mathbb P(H\vert E)}$ is the Likely Ratio

The simple form of Bayes’ formula is:

How did we get to the expression on the right? $\mathbb P(D\cap B)=\mathbb P(B\cap D)$ which $\implies\mathbb P(D\vert B)\mathbb P(B)=\mathbb P(B\vert D)\mathbb P(D)$. The denominator $\mathbb P(B)$ can be broken down intuitively into $\mathbb P(B\cap D)+\mathbb P(B\cap D^c)$. And then we turn the intersections in the denominator into conditional probability form.

The general form of Bayes’ formula is:

This is identical to above except some conditions need to be satisfied:

Example: three prisoners

Scenario:

• Prisoner A, B, and C are to be executed
• One of the prisoners are randomly chosen by the governor to be pardoned
• Warden knows who is pardoned, but can’t disclose
• Prisoner begs the warden to know which one of the other prisoner is not pardoned
• If B is pardoned, C’s name is given; if C is pardoned, B’s name is given; if A is pardoned, B or C’s name is given (chosen by a random coin flip)
• Warden tells A: “B is not pardoned

Result: Given the information, C is now twice more likely to be pardoned than A, why?

Solution:

Let

and let

so we can say that the probability of each prisoner pardoned is $^1/_3$. These are the Prior Probability. This also implies that $A, B, C$ are all disjoint, which satisfies the conditions for the general Bayes’ formula.

Since we safely assume that the warden never lies, we can list the conditional probability of $b$ given each of events $A, B,C$. The probability of $b$ given $B$ (probability of warden saying prisoner B is not pardoned while prisoner B is pardoned) is 0. Next, the probability of $b$ given prisoner A being pardoned is $^1/_2$ because of the random coin toss. Last, the probability of $b$ given prisoner C being pardoned is 1.

Now we may use Bayes’ formula to compute $\mathbb P(A\vert b)$

… and $\mathbb P(C\vert b)$.

The probability of C being pardoned, thus, is proved to be twice the probability of A pardoned.

Example: Screening Example II

Suppose

Also let $B=\{\text{Screening test is positive}\}$, so suppose

Given these information, we may ask:

• Probability of positive test
• Probability that $C_i$ ($i=1,2$) is defective when the test resulted positive
• Probability both components are defective when the test resulted positive
• Probability of testing error

Probability of positive test:

Probability of defective:

Probability of positive test:

see slides

## Independence

Events $A$ and $B$ are independent if the probability of the intersection of $A$ and $B$ equals to the product of the probability of each.

If $A$ and $B$ are independent, then

If $\mathbb P(A)=1$, then $A$ is independent of all $B$.

If $A$ and $B$ are non-trivial and mutually exclusive ($A\cap B=\emptyset$) then they cannot be independent.

If $A\subset B$ then they cannot be independent.

If $A$ and $B$ are dependent, the probability of $A\cap B$ can still be calculated.

## System of Independent Components

Consider a system in system and parallel.

In series:

graph LR i((input))-->a a-->b b-->c c-->o((output))

In parallel:

graph LR s((input))-->a s-->b s-->c a-->o((output)) b-->o c-->o

The reliability of the system is the rate the of getting a correct output given an input.

Let

And we assume $A$, $B$, and $C$ are independent. so

Example: consider that each of the component $A$, $B$, or $C$ have the reliability of $\mathbb P(A)=\mathbb P(B)=\mathbb P(C)=0.95$.

In series, the reliability is:

In parallel, we compute the reliability by computing the contrary (when the system will fail):

## Conditional Independence

Definition:

$T_1,T_2,\dotsc,T_n$ are conditionally independent given the event $B$ if:

• Conditional independence does not imply unconditional independence (and vise versa)
• Conditional independence given $B$ does not imply conditional independence given $B^c$
• Both conditional independences are assumed together in applications ?

## Sequential Bayes’ Formula

Let $S_i$ be the outcome of $i$-th test:

The outcome will evolve as we obtain more information. $\pi_0$ is evaluated with no historical information or it is given.

where $S_i$ are outcome as a sequence. and the ‘data’ at step $k$ is $I_k=\bigcap_{i=1}^k S_i$

So assume that $S_i$ are independent given some event $E$ and also given $E^c$, then for $k=1,2,3,\dotsc,n$:

This means that the new probability $\pi_k$ depends on $\pi_{k-1}$ which is the previous probability, and $\mathbb P(S_k\vert E)$. $S_k$ is the new piece of data. $I_k$ is the intersection of $S_k$ and all previous data ($S_{k-1}, S_{k-2},\dotsc$).

Example: pseudo code

Input

Outcomes for the $n$ tests: $(S_1,S_2,S_3,\dotsc,S_n)=(1,0,1,\dotsc,0)$

Probability of event of interest $E$: $\pi=\mathbb P(E)$

Sensitivity of $k^\text{th}$ test: $p_k=\mathbb P(S_k=1\vert E),\quad k=1,2,\dotsc n$

Specificity of $k^{\text{th}}$ test: $q_k=\mathbb P(S_k=0\vert E),\quad k=1,2,\dotsc,n$

Output

Example: demine whether a component of a device is fault or not, base on $n$ experiments

Example: whether if a patient has cancer or not

Example: Spam e-mail detection