In [6]:
import pymc3 as pm
import numpy as np
from scipy.stats import poisson, binom, norm
%matplotlib inline

In [20]:
data_1k = norm.rvs(50, 2, size=1000)
data_100 = norm.rvs(50, 2, size=100)
data_1 = norm.rvs(50, 2, size=1)

In [22]:
with pm.Model() as model:
    mu = pm.Exponential('mu', lam=1)
    sd = pm.Exponential('sig', lam=1)
    
    n = pm.Normal('n', mu=mu, sd=sd, observed=data_1)
    
    start = {'mu':1, 'sig': 1}
    step = pm.Metropolis()
    trace = pm.sample(1000, step=step, start=start)
pm.traceplot(trace)


 [-----------------100%-----------------] 1000 of 1000 complete in 0.6 sec
Out[22]:
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x1219457b8>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x12198cb00>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x12194ffd0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x121a0c940>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x121a54ac8>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x121a8fe10>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x121ad7f98>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x121d19be0>]], dtype=object)

In [21]:
with pm.Model() as model:
    mu = pm.Exponential('mu', lam=1)
    sd = pm.Exponential('sig', lam=1)
    
    n = pm.Normal('n', mu=mu, sd=sd, observed=data_1k)
    
    start = {'mu':1, 'sig': 1}
    step = pm.Metropolis()
    trace = pm.sample(1000, step=step, start=start)
pm.traceplot(trace)


INFO (theano.gof.compilelock): Refreshing lock /Users/ericmjl/.theano/compiledir_Darwin-15.2.0-x86_64-i386-64bit-i386-3.4.4-64/lock_dir/lock
INFO:theano.gof.compilelock:Refreshing lock /Users/ericmjl/.theano/compiledir_Darwin-15.2.0-x86_64-i386-64bit-i386-3.4.4-64/lock_dir/lock
 [-----------------100%-----------------] 1000 of 1000 complete in 0.4 sec
Out[21]:
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x120f0a1d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x120f5fba8>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x120fa8f28>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x120fe2dd8>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x12112cf60>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x121167cf8>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x1211aee80>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x1211efba8>]], dtype=object)

In [23]:
with pm.Model() as model:
    mu = pm.Exponential('mu', lam=1)
    sd = pm.Exponential('sig', lam=1)
    
    n = pm.Normal('n', mu=mu, sd=sd, observed=data_100)
    
    start = {'mu':1, 'sig': 1}
    step = pm.Metropolis()
    trace = pm.sample(1000, step=step, start=start)
pm.traceplot(trace)


 [-----------------100%-----------------] 1000 of 1000 complete in 1.0 sec
Out[23]:
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x1216bde10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x121752b70>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x12173ba20>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x1202b0b70>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x11f8acd30>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x11e854898>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x12214ca20>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x1223a3908>]], dtype=object)

In [ ]: