How To Think Like A Computer Scientist

Pitfalls of Probability
Lecture 18
CS 15-251
You have 3 dice:
A
Higher Number Wins
2
6
7
1
B
5 9
3
C
4 8
2 Players each rolls a die.
The player with the higher
number wins
Which die is
best to have –
A, B, or C ?
A is better than B
2
6
1
5 9
7
When they are rolled, there are 9
equally likes outcomes
2 1
2 5
2 9
6 1
6 5
6 9
7 1
7 5
7 9
A beats B 5/9 of the time
B is better than C
1
5 9
3
4 8
When they are rolled, there are 9
equally likes outcomes
1 3
1 4
1 8
5 3
5 4
5 8
9 3
9 4
9 8
B beats C 5/9 of the time
A beats B with Prob. 5/9
B beats C with Prob. 5/9
QUESTION: Without explicitly doing
the calculation, can you see the
probability that A will beat C ?
QUESTION: If you chose first, which
die would you take?
QUESTION: If you chose the second,
which die would you take?
C is better than A!
3
4 8
2
6
When they are rolled, there are 9
equally likes outcomes
3 2
3 6
3 7
4 2
4 6
4 7
8 2
8 6
8 7
C beats A 5/9 of the time!
7
2
6
1
5 9
7
3
4 8
First Moral
“Obvious” properties, such as
transitivity, associativity,
commutativity, etc… need to be
rigorously argued because sometimes
they are FALSE.
Second Moral
When reasoning about probabilities….
Stay on your toes!
Third Moral
To make money from a sucker in a bar,
offer him the first choice of die. (allow
him to change to your “lucky” die any
time he wants)
Coming up next…
More of the pitfalls of probability…
A single summary statistic (such as an
average) may have several different
possible explanations…
US News & World Report 1983
# of doctors
Average salary (1982 $)
1970
334,000
$103,900
1982
480,000
99,950
“Physicians are growing in number, but
not in pay”
Thrust of article: Market forces are at work
Possibility:
Doctors earn more than ever, but many old doctors
have retired and been replaced with younger ones.
Name a body part that almost everyone
on earth had an above average number
of
Fingers
• Almost everyone has 10
• More people are missing some than
have extras (total fingers missing > #
of extras)
•Average: 9.99 …
Almost everyone can
be above average!
Rare Disease
•A person is selected at random and given a
test for the rare disease “painanosufulitis”
•Only 1/10,000 people have it
•The test is 99% accurate: it gives the wrong
answer (positive/negative) only 1% of the
time
•The Person tests POSITIVE
Does he have the disease?
What is the probability that he has the
disease?
•Suppose there are k people in the
population
•At most k/10,000 have the
disease
•But k/100 have false test results
•So  k/100 – k/10,000 have false
test results but have no disease!
That’s about 100 times more
likely he got a false positive.
Several years ago Berkeley faced
a law suit …
1. % of make applicants admitted to
graduate school was 10%
2. % of female applicants admitted to
graduate school was 5%
Grounds for discrimination?
SUIT
Berkeley did a survey of its
departments to find out which
ones were at fault
The result was
SHOCKING…
Every Department is more likely to
admit a female than a male
#of females accepted
to department X
#of female applicants
to department X
>
#of males accepted
to department X
#of male applicants
to department X
How can this be ?
Answer
Women tend to apply to departmebts
that admit a smaller percentage of
their applicants
Women
Depart
ment
Men
Applied
Accepted
Applied
Accepted
A
99
4
1
0
B
1
1
99
10
TOTAL
100
5
100
10
Let’s assume
3) Males and females
have the same
distribution of academic
success
1987
Department of Transportation
requires that each month all
airlines report their “on-time
record”
# of on-time flights landing at nation’s
30 busiest airports
# of total flights into those airports
Newpapers would publish these
data…
Meaningless junk!
Different airlines serve different
airports with different frequency
An airline sending most of its planes
into fair weather airports will crush an
airline fling mostly into foggy airports
It can even happen that an airline
has a better record at each airport,
but gets a worse overall rating by
this method.
A) American West
B) Alaska Airlines
A
LA
Phoenix
San Diego
SF
Seattle
OEVRALL
B
% on
time
#
flights
% on
time
#
flights
88.9
94.8
91.7
83.1
85.8
86.7
559
233
232
605
2146
3775
85.6
92.1
85.5
71.3
76.7
89.1
811
5255
448
449
262
7225
A beats B in each airport
B has a better overall rating!
Computer Performance Analysis
SYSTEM
Benchmark
6502
8080
Block
41.16
51.80
Sieve
63.17
48.08
SUM
104.33
99.58
Average
52.17
49.79
6502
as base
8080
as base
Benchmark
6502
8080
6502
8080
Block
1.00
1.25
0.80
1.00
Sieve
1.00
0.76
1.31
1.00
SUM
2.00
2.01
2.11
2.00
Average
1.00
1.01
1.06
1.00
Ratio of total: 6502 takes 4.7% more than 8080
6502 as base: 6502 takes 1% less than 8080
8080 as base: 6502 takes 6% more than 8080
Patterson and Sequin (1982)
Code Size on RISC-I vs. Z8002
RISC AS
BASE
Benchmark
RISC
Z8002
RISC
Z8002
E-String Search
140
126
1.0
0.9
F-Bit Test
120
180
1.0
1.5
H-Linked List
176
141
1.0
0.8
K-Bit Matrix
288
374
1.0
1.3
I-Quick Sort
992
1091
1.0
1.1
Ackerman(3,6)
144
302
1.0
2.1
Recursive 2Sort
2736
1368
1.0
0.5
Puzzle-S
2796
1398
1.0
0.51
Puzzle-P
752
602
1.0
0.8
SED
17720
17720
1.0
1.0
Hanoi Tower
96
240
1.0
2.5
SUM
25960
23542
11.0
13.0
Average
2360
2140
1.0
1.18
A Bridge Hand has 13 cards. What
distribution of the 4 suits is most
likely?
Examples:
5
4
4
4
3
4
4
3
3
3
3
3
2?
2?
3?
3?
4333
3
13  13 
      4
4 3
4432
2
13  13  13 
         4  3
4 3 2
5332
2
13  13  13 
         4  3
5 3 2
You walk into a pet shop. There
are two parrots in a cage.
Shop owner says “At least one of the two is male”
What is the chance they are both male?
FF
FM
1/3 chance they are both
MF
male
MM
Shop owner says “The dark one is male”
FF
FM
1/2 chance they are both
MF
male
MM
Oct 93. Press Release
Crime Crisis in Florida
9 foreign tourists killed that year in
the state of Florida
Result:
1. German’s Advise their citizens not
to visit Florida
2. All Indicative markings are removed
from US. Rental Cars
Suppose that each day there is a low
probability p=1/365 of some foreign
tourist dying somwhere in Florida
(independent)
(Thus, we get that the expected # of
fatalities is 1 per year --- fairly low)
Probability of  9 means in a given year
 365  i
365i

 p (1  p)

i 9  i 
 0.122 or 1.2%
365
Fairly low
Probability that in a given decade
Florida will have a bloody year for
foreign tourists:
1 - (1 - 0.012) 10 = 0.2179 = 21%
The killing could easily be random
fluctuations, not sufficient evidence to
damage their economy and scare people
A Voting Puzzle
N (odd) people, each of whom has a
random bit (50/50) on his/her forhead.
No communication allowed. Each person
goes to a private voting booth and casts
a vote for either 1 or 0. If the outcome
of the election coincided with the
parity of the N bits, we say the voters
“win” the election
How do voters maximize the probability
of winning?
Notice:
Each individual has no information
about the parity
Beware of the Fallacy!
Since each individual is wrong half the
time, the outcome of the election is
wrong half the time
Cf. [BG] Random Oracles
PARITY – PR  PPR
Solution:
NOTE – To know parity is equivalent to
knowing the bit on your forehead
STRATEGY: Each person assumes the bit on
his/her head is the same as the majority of
bits sh/she sees. Vote accordingly (in the
case of even split, vote 0).
ANALYSIS: The strategy works so long as
the number of 1’s is not exactly one more
than the number of 0’s.
Probability
N
 
N
Of winning

1 2  N  1 1
2
O( N )
Optimal Strategy
IF N = 1 mod 4 Vote your Bit
N = 3 mod 4 Vote opposite Bit
50% + 1/O(N) chance of winning
EX: N = 3
1
3
3
1
Situations
Situations
Situations
Situations
All 0’s
Single 1
Two 1’s
Three 1’s
VOTE
1
1
0
0
Correct 6/8 = 75% of the time

0
1
0
1
0 |0 1|0 0 1 1|00001111
The guy in the first packet assumes he has a
zero on his forehead. He votes accordingly.
If the other guys see that he indeed have a
zero in his head, they assure his vote carries
the election by splitting the vote in each
packet.
0 |0 1|0 0 1 1|00001111
The guys in the second packet assume
the  of their two bits is zero.
If they are correct, the guys in the
later packets slit their votes..
In general, if the people in a packet see
that some lower packet has a bit-wise
 of 0, they slit their vote. Otherwise
they assume their packet ’s to 0 and
vote accordingly.
New Chicago Puzzle
Each person has a private random
bit
Now, what is their chance of
winning the election?
Voting in Chicago
In Chicago people can vote as many times as
they please
Strategy: each person behaves as a packet
Number the people from 1 to N. Person I
votes 0 times if any lower number person has
a 0 on his head. Otherwise person I assumes
he has a 0 on his head and votes 2 times.
Correct with probability 1/2N
This is clearly optimal