Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

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

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

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

  • Be the first to comment

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

    Be the first to comment

    Login to see the comments

  • mitsukuma

    Jun. 17, 2018
  • tushuhei

    Jun. 26, 2018
  • ShintaroYoshitaka

    Oct. 16, 2018
  • AyanoTakikawa

    Nov. 3, 2018
  • ssuser0f9247

    Nov. 3, 2018
  • HirosatoHano

    Nov. 4, 2018
  • YuichiKobayashi6

    Jan. 7, 2019
  • YuichiHiguchi

    Jan. 31, 2019
  • _bugna

    Feb. 1, 2019
  • JunMaruta2

    Mar. 27, 2019
  • takashimatsumoto9085

    May. 9, 2019
  • YutaroKATANO

    Jun. 26, 2019
  • ssuser94decc

    Jul. 22, 2019
  • KeisukeKanai2

    Sep. 22, 2019
  • puutan

    Oct. 9, 2019
  • mut04

    May. 2, 2020
  • HikaruYakushiji

    May. 24, 2020
  • ssusere79594

    Oct. 18, 2020
  • shinnekof

    Jan. 24, 2021
  • KoheiSakurai1

    Mar. 10, 2021

ベイズ推定の基本とPyMCによる簡単な実装例です. 関連資料: https://github.com/scipy-japan/tokyo-scipy/tree/master/006/shima__shima

Views

Total views

37,893

On Slideshare

0

From embeds

0

Number of embeds

2,326

Actions

Downloads

418

Shares

0

Comments

0

Likes

155

×