Showing posts with label Bayes' Theorem. Show all posts
Showing posts with label Bayes' Theorem. Show all posts

Bayes' Theorem_Examples


Bayes' Theorem (Bayes Rule)
If 0 $<$ P(A), P(B) $<$  1 then, $\mathsf {\large P(B|A)=\frac{P(A|B)\cdot P(B)}{{(A|B)\cdot P(B)+(A|B^c)\cdot P(B^c)}}}$ 



Example 1) Probability and Random Processes, Oxford, 3ED, p.11 
Only two factories manufacture zoggles. 20% of the zoggles from factory A and 5% from factory B are defective. Factory A produces twice as many zoggles as factory B each week. 1) What is the probability that a zoggles, randomly chosen from a weeks production, is satisfactory? 2) If the chosen zoggle is defective, what is the probability that it came from factory A. 

Example 2) 
In Orange County 51% of adults are males. An adult is randomly selected for a survey concerning credit card usage.
a. What is the prior probability that the selected adult is female?
b. It is later learned, from the survey results, that the selected adult is a cigar smoker. Data from the Substance Abuse and Mental Health Services Administration indicates that in Orange County 9.5% of males and 1.7% of females smoke cigars. Given this additional information compute the probability that the selected adult is female. 

Bayes' Theorem_Examples - solution (2)

Example) 

In Orange County 51% of adults are males. An adult is randomly selected for a survey concerning credit card usage.
a. What is the prior probability that the selected adult is a male.
b. It is later learned that the selected survey subject was smoking a cigar. Also, 9.5% of males smoke cigars, whereas 1.7% of females smoke cigars (based on data from the Substance Abuse and Mental Health Services Administration). Use this additional information to find the probability that the selected subject is a male.


$\triangleright$ Notation First!
M=male $\rightarrow M^c$ = female
C= cigar smoker $\rightarrow C^c$= not a cigar smoker  

$\triangleright$ Solution (a)
Question (a) is asking what the P(M) is  $\rightarrow$ P(M)=0.51

$\triangleright$ Solution (b)
Question (b) is asking what the P(M|C) is. 

P(M)=0.51, P($M^c$)=0.49
P(C|M)= probability of selecting male who smokes cigar = 0.095
P(C|$M^c$ ) = probability of selecting female who smokes cigar=0.017

Now, $P(M|C)= \frac {P(C|M)\cdot P(M)}{P(C|M)\cdot P(M)+P(C|M^c)\cdot P(M^c)}= \frac {0.095 \cdot 0.51}{0.095\cdot 0.51 + 0.017 \cdot 0.49}$  = 0.853 

Bayes' Theorem_Examples - solution (1)

Example) Probability and Random Processes, Oxford, 3ED, p.11 

Only two factories manufacture zoggles. 20% of the zoggles from factory A and 5% from factory B are defective. Factory A produces twice as many zoggles as factory B each week. 1) What is the probability that a zoggles, randomly chosen from a weeks production, is satisfactory? 2) If the chosen zoggle is defective, what is the probability that it came from factory A



$\triangleright$ Think First
Let D be the event that the chosen zoggle is defective. 
$\rightarrow$ $D^c$ will be the event that the chosen zoggle is NOT defective.  

Let A be the event it was made from factory A. 
$\rightarrow$ $A^c$ will be the event that was made from factory B.


$\triangleright$ Solution
The question 1) is asking what the P($D^c$) is.

Method 1) 
P($D^c$) = 1 - P(D) =1 - [P(D|A) x P(A) + P(D|P($A^c$) x P(P($A^c$) = $1-(0.2 \cdot \frac{2}{3} + 0.05 \cdot \frac {1}{3})=\frac{51}{60}$ 

Method 2) 
P($D^c$) =P($D^c$|A) x P(A) + P($D^c$|P($A^c$) x P(P($A^c$) = $0.8 \cdot \frac {2}{3}+ 0.95\cdot \frac{1}{3}=\frac{51}{60}$ = 0.85 


The question 2) is asking what the P(A|D) is.

$P(A|D)= \frac {P(A \cap D)}{P(D)}=\frac{P(D|A)\cdot P(A)}{P(D)}= \large{\frac {\frac{1}{5}\cdot \frac{2}{3}}{1-\frac{51}{60}}}$ = 0.8889