Chapter 2 Probability -...

18
Chapter 2 Probability Part 3: Probability Introduction Section 2.6 Independence Section 2.7 Bayes’ Theorem 1 / 18

Transcript of Chapter 2 Probability -...

Page 1: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Chapter 2 Probability

Part 3: Probability Introduction

Section 2.6 IndependenceSection 2.7 Bayes’ Theorem

1 / 18

Page 2: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

Recall the RANK and SEX variables in the STEM faculty example. Inthat case, knowing RANK (i.e. conditioning on it) changed theprobability that a randomly chosen member was female. OrP (F |rank) 6= P (F ).

What if the extra information you get (like conditioning on RANK)didn’t change the probability? What if P (A|B) = P (A)?

Example (Independence)

Joleb Inc. is a sales company with 350 employees. The frequency table ofSalary Category (high/low) and Color of car (red/not red) are shown inthe table:

CAR COLORred not red total

SALARY low 28 252 280high 7 63 70total 35 315 350

2 / 18

Page 3: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

Example (Independence, continued)

Does the chance of being in ahigh salary category depend onwhether or not they person has ared car?

CAR COLORred not red total

SALARY low 28 252 280high 7 63 70total 35 315 350

Suppose we randomly choose anemployee.

Let H be the event of high salary.

P (H) = 70350=0.20

We know that P (H) = 0.20, butwhat about P (H|R)?

The probability that the employeehas high salary given they have a redcar.

3 / 18

Page 4: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

Example (Independence, continued)

P (H|R) = P (H∩R)P (R) = 7/350

35/350=0.20 and P (H) = 70350=0.20

It looks like knowing that the employee has a red car doesn’t change thechance of them having a high salary. → H and R are independent.

Independent Events

7

Not Red Red!

1.00!

0.75!

0.50!

0.25!

0.00!

P(R)=0.10 P(R)=0.90

Complement of R, which means ‘not R’.

low

high P(H)=0.20 P(H|R)=0.20

Regardless of whether a person has a red car (R) or not (R), thereʼs still a 0.20 probability that they have a high salary. This says they’re

independent.

(mosaic plot)

4 / 18

Page 5: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

Example (Independence, continued)

In this special case, events H and R are said to be independent.Knowledge that the outcome is in event R does not affect the probabilitythat the outcome is in event H.

Compare the above example to the below example with DependentEvents B and H:

Dependent Events

9

B Not B!

1.00!

0.75!

0.50!

0.25!

0.00!

P(B)=0.30 P(B)=0.70

low

high P(H|B)=0.80 P(H)=0.40

The probability of having a high salary depends on whether a person has a B.S. degree (B) or not (B).

This says they’re NOT independent. P(H|B)≠P(H)

B: Person has B.S. degree!H: Person has a high salary

5 / 18

Page 6: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

For independent events A and B, P (B|A) = P (B).

How does this affect the Multiplication Rule for probability?

For independent events A and B,P (A ∩B) = P (B|A) · P (A) (always applicable)

= P (B) · P (A) (because independent)

Definition (Independence (two events))

Two events are independent if any one of the following equivalentstatements is true:

1 P (B|A) = P (B)

2 P (A|B) = P (A)

3 P (A ∩B) = P (B) · P (A)

6 / 18

Page 7: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

Example (Sequential tosses of a coin are independent)

Let H1 be the event that the first toss is a head.Let H2 be the event that the second toss is a head.

P (H2|H1) = P (H2) Because H1 & H2 are independent events= 1

2

What you flipped in the first toss doesn’t affect what you’ll get in thesecond, H1 & H2 are independent.

P (H1 ∩H2) = P (H2|H1) · P (H1)= P (H2) · P (H1) Because H1 & H2 are independent= 1

2 ·12 = 1

4

7 / 18

Page 8: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

Example (Series Circuits)

The circuit below will function only if both devices work properly. Theprobability that a device functions properly is written on the device in thegraphic.

The chance of a failure in a single device is independent of the otherdevice (it’s a matter of the integrity of the device itself). Find theprobability that the circuit functions.

Let D1 be the event that the 1st device works.Let D2 be the event that the 2nd device works.

ANS:

8 / 18

Page 9: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

Example (Parallel Circuits)

For the circuit below to function, only one of the two devices must workproperly. The devices fail independently. The probability that a devicefunctions properly is written on the device in the graphic.

Let T be the event that the top device works.Let B be the event that the bottom device works.

What is the probability that the circuit functions?

We want to find P (T ∪B).

9 / 18

Page 10: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

Example (Parallel Circuits, continued)

ANS:P (circuit functions) = P (top or bottom or both works) = P (T ∪B)

P (T ∪B) = 1− P [(T ∪B)′] {utilize the complement}= 1− P (neither works)= 1− P (T ′ ∩B′)= 1− (0.05)(0.05) = 1− (0.05)2 = 0.9975

This can also be seen by the addition rule:P (T ∪B) = P (T ) + P (B)− P (T ∩B)

= 0.95 + 0.95− (0.95)(0.95) = 0.997510 / 18

Page 11: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

Example (Three independent radars)

Three radar sets, operating independently, are set to detect any aircraftflying through a certain area. Each set has a probability of 0.02 of failingto detect a plane. If an aircraft enters the area, what is the probabilitythat it goes undetected?

(a) (0.02)3

(b) 1− (0.98)3

(c) (0.98)3

(d) 1− (0.02)3

{Also, what detection scenario goes with each probability above...}

11 / 18

Page 12: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Independence

Definition (Independence (multiple events))

The events E1, E2, . . . , En are independent if and only if for any subset ofthese events

P (Ei1 ∩ Ei2 ∩ Ei3 ∩ · · · ∩ Eik) = P (Ei1)× P (Ei2)× · · ·P (Eik).

The knowledge that the events are independent usually comes from afundamental understanding of the random experiment.

12 / 18

Page 13: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Bayes’ Theorem

Definition (From the definitions of Conditional Probability and theMultiplication Rule, we can write)

P (A|B) = P (A∩B)P (B) for P (B) > 0

= P (B|A)·P (A)P (B) for P (B) > 0

This is a useful result that lets us compute P (A|B) in terms of P (B|A).

13 / 18

Page 14: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Bayes’ Theorem

Definition (Bayes’ Theorem)

If we rewrite the denominator in the previous result using the TotalProbability Rule and the partition S = A ∪A′, we have Bayes’ Theorem...

P (A|B) = P (B|A)·P (A)P (B) for P (B) > 0

= P (B|A)·P (A)P (B|A)P (A)+P (B|A′)P (A′)

And this can be extended to any set of k mutually exclusive eventsE1, E2, . . . , Ek such that E1 ∪ E2 ∪ . . . ∪ Ek = S.

P (E1|B) = P (B|E1)·P (E1)P (B) for P (B) > 0

= P (B|E1)·P (E1)P (B|E1)P (E1)+P (B|E2)P (E2)+...+P (B|Ek)P (Ek)

NOTICE: The numerator always equals one of the terms in the sum in the denominator.14 / 18

Page 15: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Bayes’ Theorem

Example (spam filtering, calculating P (A|B) utilizing P (B|A))Suppose we’re trying to decide if an email with the word “free” in thesubject line is a spam email.

Let S be the event that an email is spam.Let F be the event that an email subject contains the word “free”.

Suppose we have the following facts:

Of all email traffic worldwide prior to filtering, 48% is spam. OrP (S) = 0.48, a marginal (or unconditional) probability.

Based on data, in the set of all spam mail, “free” occurs in the subjectline 1% of the time. Or P (F |S) = 0.01, a conditional probability.

Based on data, in the set of all non-spam mail, “free” occurs in thesubject line in 1 out of 1,000 emails. Or P (F |S′) = 0.001, aconditional probability.

15 / 18

Page 16: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Bayes’ Theorem

Example (spam filtering, calculating P (A|B) utilizing P (B|A))If an email subject line contains the word “free”, we can calculate theprobability that it is spam as:

P (S|F ) =P (F |S)P (S)

P (F |S)P (S)+P (F |S′)P (S′) =(0.01)·(0.48)

(0.01)·(0.48)+(0.001)·(0.52)

= 0.9023

Because the subject line contains “free”, the probability that the email isspam is 0.90. Without any information about a subject line, theprobability that a randomly chosen email is spam is 0.48.——————————————————————————————–Every year I send out an email to departments with the following subject:

Free Statistical Consulting Services

available for spring 2018

I may have to rethink that...16 / 18

Page 17: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Bayes’ Theorem

Example (spam filtering, calculating P (A|B) utilizing P (B|A))Mosaic Plot

Spam NotSpamNotFree

Free

17 / 18

Page 18: Chapter 2 Probability - homepage.divms.uiowa.eduhomepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch2_pt3.pdf · Bayes’ Theorem Example (spam ltering, calculating P(AjB) utilizing

Bayes’ Theorem

Example (American Lung Association)

According to the Arizona Chapter of the American Lung Association, 7.0%of the population has lung disease. Of those having lung disease, 90% aresmokers; of those not having lung disease, 25.3% are smokers.

Determine the probability that a randomly selected smoker has lungdisease.

ANS:

18 / 18