No matter how hard I look, I don’t see any difference between these two models, the programs of which are reproduced below:
import numpy as np
import pymc as pm
import arviz as azobserved_data = np.array([1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0,
1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0,
1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0,
1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0,
1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 1, 0, 1])
First:
“”"
Bernoulli model
“”"
with pm.Model() as coin_flip_Bern:prior_p = pm.Beta("p", alpha = 1, beta = 1) obs_data = pm.MutableData("observed", observed_data) likelihood = pm.Bernoulli("likelihood", p = prior_p, observed = obs_data) idata_Bern = pm.sample()
Second:
“”"
Binomial model
“”"
with pm.Model() as coin_flip_Bin:prior_p = pm.Beta("p", alpha = 1, beta = 1) obs_data = pm.MutableData("observed", observed_data) likelihood = pm.Binomial("likelihood", n = 73, p = prior_p, observed = 46) idata_Bin = pm.sample()
Do you know of any documents that explain why you should choose pm.Bernoulli
, or on the contrary choose pm.Binomial
, depending on the situation? For me, the web page PyMC is totally unclear…