MS3227week2
MS3227week2
Business
Week 2
2
Conditional probability
P(A | B) = P(AP(B)
and B)
, calculate probability of A assume that B
always happen.
3
Conditional probability and multiplicative rule
P(A and B)
P(A | B) =
P(B)
Multiplicative rule
4
Example: Age and Rank of Faculty
Given a faculty is under 40 years old, what’s the probability that he / she
is a full professor?
54 430
P(professor |< 40) = 470 , P(professor) = 1164
5
Monty Hall
Example: The Monty Hall problem
You pick a door (not open yet), say the first one.
The host who knows what behind doors, opens another door and it
is a goat. The host asks if you want to switch your choice?
You might think: I know there is one car and one goat behind the two
doors. So the probability of getting a car is 12 no matter I switch or not.
It does not matter.
7
Example: The Monty Hall problem
Actually the numbers on the door (order of door) does not matter.
2
If you switch, you will win in two out of the three cases! 3!
8
Example: The Monty Hall problem
Another explaination
9
Independence
Independence
10
Independence
Knowing that the coin landed on a head on the first toss does not
provide any useful information for determining what the coin will
land on in the second toss.
Outcomes of two tosses of a coin are independent.
Knowing that the first card drawn from a deck is an ace does
provide useful information for determining the probability of drawing
an ace in the second draw.
Outcomes of two draws from a deck of cards (w/o replacement) are
dependent.
11
Independence and Conditional Probabilities
Equivalently, one can also check the independency of the events A and B
by check whether P(B | A) = P(B)
12
Practice – Checking for Independence
Survey in US asks ”Do you agree that the widespread gun ownership
can protect citizens”?
58% of all respondents say yes.
Look at di↵erent race: 67% white, 28% black and 64% hispanic
respondents say yes respectively.
Recall that for a two-way contingency table, the two variables are
independent if the row proportions do not change from row to row.
This is consistent with the definition of independence of events since
and if the row proportions do not change from row to row, they will be
equal to the marginal probability of the column variable.
For example of the faculty, P(rank | age) 6= P(rank), the age and rank of
faculty members are dependent.
14
Multiplication rule for independent events
More generally,
P(A1 and A2 · · · and Ak ) = P(A1 ) ⇥ · · · ⇥ P(Ak )
If A1 , · · · , Ak are independent.
Exercies: If you roll a die twice, what’s the probability of getting two 1 in
a row?
1 1 1
P(1 in the first roll) ⇥ P(1 in the second roll) = ⇥ =
6 6 36 15
Practice
0.2552
16
The gambler
17
Put everything together
18
Abuse of the multiplication rule
Among the age 65 or older, only 44% are male (this is the condition
probability!), not 52%. So only 0.134 ⇥ 0.44 = 0.059 were males age
65 or older.
19
Law of total probability
Law of total probability
20
Law of total probability
21
Law of total probability
https://www.youtube.com/watch?v=PXDG5XKqutw
22
Law of total probability
23
Law of total probability
It’s hard to calculate P(B) directly, you enumerate all possible cases
of Ai and calculate P(B | Ai ) instead.
24
Example of Law of total probability
Take two cards from a well shu✏ed deck. What’s the probability that the
second card is an ace?
25
Example of Law of total probability
Life time risk of lung cancer: 12% for smoking and 1.3% for
non-smoking people.
26
Example of Law of total probability
There are three roads from your home to your office. Every morning you
pick a road at random, with probability P(L1 ) = 0.5, P(L2 ) = 0.3,
P(L3 ) = 0.2.
The probability of heavy traffic on each road is P(T1 ) = 0.8,
P(T2 ) = 0.6, P(T3 ) = 0.3. What’s the probability that you avoid heavy
traffic everyday?
27
Example of Law of total probability
28
Tree diagrams and Bayes’
Theorem
Example – Nervous Job Applicant
29
Nervous job applicant
30
Tree diagram for the nervous job applicant
·
0.3
c c e ed P(N C and S) = 0.3 ⇥ 0.9
Su
Not 0.9
nervous Fail
0.1 P(N C and S C ) = 0.3 ⇥ 0.1
Since we are interested in P(N | S), the red two have S, and the bold
one has N.
0.7 ⇥ 0.2
P(N | S) =
0.7 ⇥ 0.2 + 0.3 ⇥ 0.9
Compare with previous two slides, you get identical results! 31
Bayes’ Theorem
This is very useful for inferring the hidden causes underlying our
observations. Law of total probability is used in the denominator.
32
Medical Testing
33
Enzyme Immunoassay test for HIV
What’s the probabilitythat the tested person is infected if the test was
positive?
P(D)P(T + | D)
P(D | T +) =
P(D)P(T + | D) + P(D C )P(T + | D C )
1/300 ⇥ 0.98
=
1/300 ⇥ 0.98 + 299/300 ⇥ 0.005
= 0.394
34
Tree diagram for HIV test
e 1
s i t i v ( and +) = ⇥ 0.98
Po 300
0 . 98
Infected N e ga
1
ti ve
0 0 . 02
30 P(D and T ) = 1
⇥ 0.02
300
· 29
30 9
0
o s i t i ve P(D C and T +) = 299
300 ⇥ 0.005
P
Not 0 .005
Nega
infected ti ve
0.99 P(D C and T ) = 299
⇥ 0.995
5 300
Only the red cases are positive test results, out of them, the bold one is
D, have disease.
bold 1/300 ⇥ 0.98
P(D | T +) = =
red1 + red2 1/300 ⇥ 0.98 + 299/300 ⇥ 0.005
35
One more Bayes example..
In a sample of 100,000 emails, you found 550 are spam. Your next email
has the word “bigly”. From historical experience, you know that half of
all spam emails contains “bigly”, and only 2% non-spam email contains
that. What’s the probability that the new email is a spam?
36
One more Bayes example..
In a sample of 100,000 emails, you found 550 are spam. Your next email
has the word “bigly”. From historical experience, you know that half of
all spam emails contains “bigly”, and only 2% non-spam email contains
that. What’s the probability that the new email is a spam?
What information can you get from the statement?
550
P(spam) = 100000 = 0.0055
P(bigly | spam) = 0.5
P(bigly | non-spam) = 0.02
37
One more Bayes example..
spam 0.5
no b
5 i gl y
5
0 .00 0.5 P(spam and no bigly) = 0.0055 ⇥ 0.5
·
0. 9
94
5 bigly P(not spam and bigly) = 0.9945 ⇥ 0.02
Only the red cases have bigly, out of them, the bold one is spam, have
disease.
bold 0.0055 ⇥ 0.5
P(spam | bigly) = =
red1 + red2 0.0055 ⇥ 0.5 + 0.9945 ⇥ 0.02
38
When do you use Bayes’ theorem
If you have P(A | B) or P(AC | B), then you are all set.
You need to know P(B | A), P(B | AC ) and P(A), draw a tree
diagram. If you don’t have these, either the question is incomplete,
or you should read it again carefully.
39
The most general Bayes’ theorem
P(B | Ai )P(Ai )
P(Ai | B) =
P(B | A1 )P(A1 ) + · · · + P(B | An )P(An )
40
Counting
Counting
Example: there are 1 boy and 2 girls in the room. If you pick one
randomly, what’s the probability that this is a girl?
# success #girls 2
P= = =
# total possible cases #girls + #boys 3
41
Basic principle of counting
Selecting a team is the first experiment, then choose one player from
the team. So there are 14 ⇥ 11 = 154 possible choices in total.
42
Generalized principle of counting
If r experiments that are to be performed are such that the 1st one
may result in any of n1 possible outcomes; and if, for each of these
n1 possible outcomes, there are n2 possible outcomes of the 2nd
experiment; and if, for each of the n1 ⇥ n2 possible outcomes of the
first two experiments, there are n3 possible outcomes of the 3rd
experiment; and if..., then there is a total of n1 ⇥ n2 ⇥ · · · ⇥ nr
possible outcomes of the r experiments.
43
Generalized principle of counting
24 ⇥ 10 ⇥ 10 ⇥ 10 ⇥ 10 ⇥ 10 ⇥ 10 ⇥ 10
possible cases.
44
Generalized principle of counting
If you flip a coin 20 times and keep record of the outcome. H for
head and T for tail. How many possible outcomes in total?
220
45
Permutations
We have (A, B, C), (A, C, B), (B, A, C), (B, C, A), (C, A, B) and
(C, B, A). 6 possible cases in total.
n ⇥ (n 1) ⇥ (n 2) ⇥ · · · ⇥ 3 ⇥ 2 ⇥ 1 := n!
46
Permutations
If boys are ranked among themselves, and girls are ranked among
themselves. How many possible rankings?
20! possible rankings for boys, and 30! possible rankings for girls.
47
Permutations: More Examples
First, you have 3! ordering of the subjects, MPC, MCP, PMC, PCM,
CMP, CPM.
There are 5 ways to select the 1st letter, 4 to select the 2nd and 3
to select the 3rd so 5 ⇥ 4 ⇥ 3 = 60 ways to select when the order in
which the items are selected is relevant. When it is not relevant,
then say the group BCE is the same as BEC, CEB, CBE, EBC, ECB;
there are 3! = 6 permutations. So when the order is irrelevant, we
have 60/6 = 10 di↵erent groups
49
Combinations
possible groups.
50
Combinations: Examples
12! 12!
When it matters (12 3)! , when it does not matter, (12 3)!3! .
51
Combinations: Examples
52
Random variable
Random variable
1 for understandable, 0 for not. The sample space has 250 elements!
53
Random variable
Examples:
You toss a coin, is that head or tail?
You roll a die, what number do you get?
Number of heads in ten coin tosses.
Stock return of tomorrow.
Next month sales revenue for a grocery store.
54
Discrete and continuous random variable
55
Probability mass function
1
P(X = 1) = P({TH}) + P({HT }) = 2
1
P(X = 2) = P({HH}) = 4
56
Probability mass function
57
Summary
Concept of independence
58