ベイズの定理と ベイズ統計学

ベイズの定理と
ベイズ統計学
東京工業大学大学院
社会理工学研究科
前川眞一
Coffe or Tea


珈琲と紅茶のどちらが好きかと聞いた場合、
Star Trek のファンの 60% が紅茶を好む。
Star Wars のファンの 95%が珈琲を好む。
ある人が紅茶を好むと分かったとき、その人が
ST のファンである確率はいくつか?
2
ベイズの定理
3
条件付き確率、同時確率、周辺確率
4
ベイズの定理の証明
5
ベイズの定理
6
事後確率の計算
7
条件付き確率の表
8
同時確率の計算
9
事後確率の計算
10
Coffe or Tea (revisited)




珈琲と紅茶のどちらが好きかと聞いた場合、
Star Trek のファンの 40% が紅茶を好む。
Star Wars のファンの 95%が珈琲を好む。
ある人が紅茶を好むと分かったとき、その人が
ST のファンである確率はいくつか?
ST のファンは全人口の 10%、
SW のファンは全人口の 90% であるとする。
A1=tea, A2=coffe, B1=SW, B2=ST
11
Coffee or Tea (CPT)
tea
coffe
Conditional Probability P(A|B)
sw
st
P(A|B1) P(A|B2)
A1
0.05
0.4
A2
0.95
0.6
sum
1
1
Prior Probability of B (P(B)
sw
st
B1
B2
0.9
0.1
12
Coffee or Tea (joint and post)
tea
coffe
tea
coffe
Joint Probability P(A,B)
sw
st
B1
B2
A1
0.045
A2
0.855
P(B)
0.9
Marginal Probability P(A)
P(A)
0.04
0.06
0.1
Posterior Probability P(B|A)
sw
st
B1
B2
sum
A1
0.529
0.471
A2
0.934
0.066
0.085
0.915
1
1
1
13
Coffee or Tea (Cross Table)
Cross Table
sw
B1
A1
A2
marginal
Marginal Freq
st
B2
45
855
900
marginal
40
85
60
915
100
1000 total
N
1000
14
Examples using Excel

Standard Problems

Three Prisoners Problem and its variations.
Monty Hall Problem
Boy or Girl Problem


15
Three Prisoners Problem 3囚人問題
16
Three Prisoners Problem 3囚人問題
17
Three Prisoners Problem 3囚人問題
18
Three Prisoners Problem 3囚人問題
19
Three Prisoners Problem 3囚人問題
20
Solution of 2)
Conditional Probability P(A|B)
A free B free C free
P(A|B1) P(A|B2) P(A|B3)
A1: A dies
0
0
0
A2: B dies
0.5
0
1
A3: C dies
0.5
1
0
sum
1
1
1
Joint Probability P(A,B)
A free B free
B1
B2
A1: A dies 0.0000 0.0000
A2: B dies 0.1667 0.0000
A3: C dies 0.1667 0.3333
sum
0.3333 0.3333
Prior Probability of B (P(B)
Posterior Probability P(B|A)
A free B free C free
B1
B2
B3
A1: A dies #DIV/0! #DIV/0! #DIV/0!
A2: B dies
0.333 0.000
0.667
A3: C dies
0.333 0.667
0.000
B1
B2
B3
0.333 0.333 0.333
Marginal Probability P(A)
C free
B3
P(A)
0.0000 0.0000
0.3333 0.5000
0.0000 0.5000
0.3333 1.0000
sum
#DIV/0!
1.000
1.000
21
Three Prosiners Problem

There are three prisoners, A, B, and C,
two of whom will be released and the
other executed.
A asks the warden to tell him the name of
one of the others who will be released.
As the question is not directly about A's
fate, the warden obliges.
Assuming the warden's truthfulness,
there are now only two possibilities for
who will be executed: A, and either B or C.
Did A gain any information as to his own
fate, that is, does he change his estimate
of the chances he will be executed?
22
Monty Hall Problem

Suppose you're on a game show, and
you're given the choice of 3 doors:
Behind one door is a car;
behind the other 2 doors, goats.
You pick a door, say “A”, and the host,
who knows what's behind the doors,
opens another door, say “B”,
which has a goat. He then says to you,
"Do you want to pick door “C” ?"
Is it to your advantage to switch your
choice? (Let’s Make a Deal: 1963-1976)
23
Solution
Monty Hall
Conditional Probability P(A|B)
Aa
P(A|B1)
a
b
c
sum
Joint Probability P(A,B)
Ba
P(A|B2)
0
0.5
0.5
1
Ca
P(A|B3)
0
0
1
1
0
1
0
1
Prior Probability of B (P(B)
B1
B2
0.333
a
b
c
sum
Ba
B2
0.000
0.000
0.333
0.333
Ca
B3
0.000
0.333
0.000
0.333
P(A)
0.0000
0.5000
0.5000
1.0000
Posterior Probability P(B|A)
Aa
B1
B3
0.333
Aa
B1
0.000
0.167
0.167
0.333
Marginal Probability P(A
0.333
a
b
c
Ba
B2
0.000
0.333
0.333
Ca
B3
0.000
0.000
0.667
sum
0.000
0.000
0.667
1.000
0.000
1.000
Aa = Car is behind door A and you pick door a.
Ba = Car is behind door B and you pick door a
Ca = Car is behind door C and you pick door a.
a = Host opens door A
b = Host opens door B
24
Boy or Girl Problem (not Bayes)


ある男性にもうひとりの兄弟がいることが解っている。
その人が女性である確率は?
ある男性にもうひとりの年下の兄弟がいることが解っている。
その人が女性である確率は?
主婦の会話:
あなたのお子さんは何人?
ふたりよ。
男の子はいるの?
居ますよ。
二人とも男の子である確率は?

25
複数の観測値(独立な場合)
26
2回のコイン投げ
27
複数の原因

同時事後分布を計算し、その周辺化を行う。
28
2回のテストの得点
29
2回のテストの得点
正規分布だと合計点が十分統計量。
30
カテゴリに数値が付与されている場合
31
A のカテゴリに数値が付与されている場合
32
カテゴリに数値が付与されている場合
33
正規分布的なもの
34
正規分布的なもの
35
正規分布的なもの
36
複数の観測値と事前分布

十分統計量を探す。
37
B カテゴリが数値の場合の事前分布



自然共役分布を用いると都合がよい。
事前分布と事後分布が同じ形になるように
事前分布を選ぶ。
事前分布は尤度関数の形に依存する。
38