Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# x=1: 袋a, x=0: 袋b
# y=1: 赤玉, y=0: 白玉
def ball_model_no_if():
x = pyro.sample("x", dist.Bernoulli(0.5))
# xの値に応じてyの割合を変更
y = pyro.sample("y", dist.Bernoulli(2.0/3.0)) * x + pyro.sample("y", dist.Bernoulli(1.0/4.0)) * (1 - x)
return y
# plateを用いてi.i.dサンプリング
with pyro.plate("plate", size=10000):
samples = ball_model_no_if()
print("var_type is {}, shape = {}".format(type(samples), samples.shape))
plt.hist(samples, bins=20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment