# coding: utf-8
# In[2]:
get_ipython().run_line_magic('matplotlib', 'inline')
import pymc3 as pm
import numpy as np
import seaborn as sns
# First, let's run an analysis of 100 binomial samples, with zero positive outcomes:
# In[3]:
n1 = 100
x1 = 0
# In[6]:
with pm.Model() as first_dataset:
θ = pm.Beta('θ', 1, 1)
x = pm.Binomial('x', n=n1, p=θ, observed=x1)
trace1 = pm.sample(2000)
# The parameter estimate is 0.012, with a credible interval of length 0.031.
# In[7]:
pm.summary(trace1)
# Now, let's add another 100 samples, but this time with 10 positive outcomes:
# In[8]:
n2 = 100
x2 = 10
with pm.Model() as combined_dataset:
θ = pm.Beta('θ', 1, 1)
x = pm.Binomial('x', n=n1+n2, p=θ, observed=x1+x2)
trace2 = pm.sample(2000)
# In[9]:
pm.summary(trace2)
# Notice that the credible interval is twice as large, even with a doubling of the sample size!