SlideShare a Scribd company logo
1
•
•
•
•
•
•
•
2
3
4
Pr[✓|x] =
Pr[x|✓] Pr[✓]
P
✓ Pr[x|✓] Pr[✓]
5
6
7
•
•
•
8
Pr[ θ, Z, D ]
Pr[ θ | D ]
Z D
9
X
y2Dom(Y )
Pr[X, y] = Pr[X]
X
y2Dom(Y )
Pr[y|X] = Pr[X] ⇥ 1
+ =
10
Pr[✓, D] = Pr[✓|D] Pr[D] Pr[✓|D] =
Pr[✓, D]
Pr[D]
D
Z D
D
Pr[✓|D] =
Pr[✓, D]
Pr[D]
=
Pr[✓, D]
P
✓ Pr[✓, D]
=
Pr[D|✓] Pr[✓]
P
✓ Pr[D|✓] Pr[✓]
11
•
•
•
•
•
•
12
1. N Poisson(ξ)
2. θ Dirichlet(θ ; α)
3. For n in 1, …, N
(a) zn Categorical(zn | θ)
(b) wn Categorical(wn | zn; β)
13
z, z=1, . . . , K
M N
✓ t
↵
w
14
1. N Poisson(ξ)
2. θ Dirichlet(θ ; α)
3. For n in 1 … N
(a) zn Categorical(zn | θ)
(b) wn Categorical(wn | zn; β)
✤
Pr[w, z, ✓; ↵, ] = Pr[✓|↵]
NY
n=1
Pr[zn|✓] Pr[wn|zn, zn ]
15
16
•
•
•
•
•
•
•
•
•
•
17
1. μ Normal(0.0, 0.12)
2. For i in 1 … N
(a) xi Normal(μ, 1.02)
μ x
N
• x
• μ
Pr[µ|x1, . . . , xN ] = Pr[µ|{x}]
18
•
•
•
•
•
19
mu = Normal('mu', 0, 1 / (0.1 ** 2))
✤
x
20
x = Normal('x', mu=mu, tau=1/(1.0**2),
value=x_sample, observed=True)
x
21
M = MCMC(input=[mu, x])
M.sample(iter=10000)
✤
22
Matplot.plot(mu)
23
1. p Beta(1.0, 1.0)
2. μ0 Normal(-1, 1.0)
3. μ1 Normal(1, 1.0)
4. For i in 1 … N
(a) yi Bernoulli(p)
(b) μ = μ0 if yi = 0; μ1 if yi = 1
(c) xi Normal(μ, 1.02)
y x
N
✤ xi
p μ0 μ1
24
@deterministic(plot=False)
def mu(y=y, mu0=mu0, mu1=mu1):
out = np.empty_like(y, dtype=np.float)
out[y == 0] = mu0
out[y == 1] = mu1
return out
25
•
•
•
•
•
•
•
•
•
26

More Related Content

PyMCがあれば,ベイズ推定でもう泣いたりなんかしない