O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

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

ベイズ推定の基本とPyMCによる簡単な実装例です.

関連資料: https://github.com/scipy-japan/tokyo-scipy/tree/master/006/shima__shima

  • Seja o primeiro a comentar

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

  1. 1. 1
  2. 2. • • • • • • • 2
  3. 3. 3
  4. 4. 4 Pr[✓|x] = Pr[x|✓] Pr[✓] P ✓ Pr[x|✓] Pr[✓]
  5. 5. 5
  6. 6. 6
  7. 7. 7 • • •
  8. 8. 8 Pr[ θ, Z, D ] Pr[ θ | D ] Z D
  9. 9. 9 X y2Dom(Y ) Pr[X, y] = Pr[X] X y2Dom(Y ) Pr[y|X] = Pr[X] ⇥ 1 + =
  10. 10. 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. 11. 11 • • • • • •
  12. 12. 12 1. N Poisson(ξ) 2. θ Dirichlet(θ ; α) 3. For n in 1, …, N (a) zn Categorical(zn | θ) (b) wn Categorical(wn | zn; β)
  13. 13. 13 z, z=1, . . . , K M N ✓ t ↵ w
  14. 14. 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. 15. 15
  16. 16. 16 • • • • • • • • • •
  17. 17. 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. 18. 18 • • • • •
  19. 19. 19 mu = Normal('mu', 0, 1 / (0.1 ** 2)) ✤
  20. 20. x 20 x = Normal('x', mu=mu, tau=1/(1.0**2), value=x_sample, observed=True) x
  21. 21. 21 M = MCMC(input=[mu, x]) M.sample(iter=10000) ✤
  22. 22. 22 Matplot.plot(mu)
  23. 23. 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. 24. 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. 25. 25
  26. 26. • • • • • • • • • 26

×