\begin{Verbatim}[commandchars=\\\{\}]
\PY{k+kn}{import} \PY{n+nn}{pymc}
\PY{k+kn}{import} \PY{n+nn}{numpy} \PY{k+kn}{as} \PY{n+nn}{np}

\PY{k}{def} \PY{n+nf}{glm\PYZus{}node\PYZus{}setup}\PY{p}{(}\PY{n}{cascade}\PY{p}{,} \PY{n}{y\PYZus{}obs}\PY{p}{,} \PY{n}{prior}\PY{o}{=}\PY{n+nb+bp}{None}\PY{p}{,} \PY{o}{*}\PY{n}{args}\PY{p}{,} \PY{o}{*}\PY{o}{*}\PY{n}{kwargs}\PY{p}{)}\PY{p}{:}
    \PY{l+s+sd}{\PYZdq{}\PYZdq{}\PYZdq{}}
\PY{l+s+sd}{    Build an IC PyMC node\PYZhy{}level model from:}
\PY{l+s+sd}{        \PYZhy{}observed cascades: cascade}
\PY{l+s+sd}{        \PYZhy{}outcome vector: y\PYZus{}obs}
\PY{l+s+sd}{        \PYZhy{}desired PyMC prior and parameters: prior, *args}
\PY{l+s+sd}{    Note: we use the glm formulation: y = Bernoulli[f(x.dot(theta))]}
\PY{l+s+sd}{    \PYZdq{}\PYZdq{}\PYZdq{}}
    \PY{n}{n\PYZus{}nodes} \PY{o}{=} \PY{n+nb}{len}\PY{p}{(}\PY{n}{cascade}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}

    \PY{c}{\PYZsh{} Container class for node\PYZsq{}s parents}
    \PY{n}{theta} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{empty}\PY{p}{(}\PY{n}{n\PYZus{}nodes}\PY{p}{,} \PY{n}{dtype}\PY{o}{=}\PY{n+nb}{object}\PY{p}{)}
    \PY{k}{for} \PY{n}{j} \PY{o+ow}{in} \PY{n+nb}{xrange}\PY{p}{(}\PY{n}{n\PYZus{}nodes}\PY{p}{)}\PY{p}{:}
        \PY{k}{if} \PY{n}{prior} \PY{o+ow}{is} \PY{n+nb+bp}{None}\PY{p}{:}
            \PY{n}{theta}\PY{p}{[}\PY{n}{j}\PY{p}{]} \PY{o}{=} \PY{n}{pymc}\PY{o}{.}\PY{n}{Beta}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{theta\PYZus{}\PYZob{}\PYZcb{}}\PY{l+s}{\PYZsq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{j}\PY{p}{)}\PY{p}{,} \PY{n}{alpha}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{,} \PY{n}{beta}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{)}
        \PY{k}{else}\PY{p}{:}
            \PY{n}{theta}\PY{p}{[}\PY{n}{j}\PY{p}{]} \PY{o}{=} \PY{n}{prior}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{theta\PYZus{}\PYZob{}\PYZcb{}}\PY{l+s}{\PYZsq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{j}\PY{p}{)}\PY{p}{,} \PY{o}{*}\PY{n}{args}\PY{p}{,} \PY{o}{*}\PY{o}{*}\PY{n}{kwargs}\PY{p}{)}

    \PY{c}{\PYZsh{} Observed container class for cascade realization}
    \PY{n}{x} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{empty}\PY{p}{(}\PY{n}{n\PYZus{}nodes}\PY{p}{,} \PY{n}{dtype}\PY{o}{=}\PY{n+nb}{object}\PY{p}{)}
    \PY{k}{for} \PY{n}{i}\PY{p}{,} \PY{n}{val} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{cascade}\PY{o}{.}\PY{n}{T}\PY{p}{)}\PY{p}{:}
        \PY{n}{x}\PY{p}{[}\PY{n}{i}\PY{p}{]} \PY{o}{=} \PY{n}{pymc}\PY{o}{.}\PY{n}{Normal}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{x\PYZus{}\PYZob{}\PYZcb{}}\PY{l+s}{\PYZsq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{i}\PY{p}{)}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{,} \PY{n}{value}\PY{o}{=}\PY{n}{val}\PY{p}{,} \PY{n}{observed}\PY{o}{=}\PY{n+nb+bp}{True}\PY{p}{)}

    \PY{n+nd}{@pymc.deterministic}
    \PY{k}{def} \PY{n+nf}{glm\PYZus{}p}\PY{p}{(}\PY{n}{x}\PY{o}{=}\PY{n}{x}\PY{p}{,} \PY{n}{theta}\PY{o}{=}\PY{n}{theta}\PY{p}{)}\PY{p}{:}
        \PY{k}{return} \PY{l+m+mf}{1.} \PY{o}{\PYZhy{}} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{x}\PY{o}{.}\PY{n}{dot}\PY{p}{(}\PY{n}{theta}\PY{p}{)}\PY{p}{)}

    \PY{n+nd}{@pymc.observed}
    \PY{k}{def} \PY{n+nf}{y}\PY{p}{(}\PY{n}{glm\PYZus{}p}\PY{o}{=}\PY{n}{glm\PYZus{}p}\PY{p}{,} \PY{n}{value}\PY{o}{=}\PY{n}{y\PYZus{}obs}\PY{p}{)}\PY{p}{:}
        \PY{k}{return} \PY{n}{pymc}\PY{o}{.}\PY{n}{bernoulli\PYZus{}like}\PY{p}{(}\PY{n}{value}\PY{p}{,} \PY{n}{glm\PYZus{}p}\PY{p}{)}

    \PY{k}{return} \PY{n}{pymc}\PY{o}{.}\PY{n}{Model}\PY{p}{(}\PY{p}{[}\PY{n}{y}\PY{p}{,} \PY{n}{pymc}\PY{o}{.}\PY{n}{Container}\PY{p}{(}\PY{n}{theta}\PY{p}{)}\PY{p}{,} \PY{n}{pymc}\PY{o}{.}\PY{n}{Container}\PY{p}{(}\PY{n}{x}\PY{p}{)}\PY{p}{]}\PY{p}{)}


\PY{k}{def} \PY{n+nf}{mc\PYZus{}graph\PYZus{}setup}\PY{p}{(}\PY{n}{infected}\PY{p}{,} \PY{n}{susceptible}\PY{p}{,} \PY{n}{prior}\PY{o}{=}\PY{n+nb+bp}{None}\PY{p}{,} \PY{o}{*}\PY{n}{args}\PY{p}{,} \PY{o}{*}\PY{o}{*}\PY{n}{kwargs}\PY{p}{)}\PY{p}{:}
    \PY{l+s+sd}{\PYZdq{}\PYZdq{}\PYZdq{}}
\PY{l+s+sd}{    Build an IC PyMC graph\PYZhy{}level model from:}
\PY{l+s+sd}{        \PYZhy{}infected nodes over time: list/tuple of list/tuple of np.array}
\PY{l+s+sd}{        \PYZhy{}susceptible nodes over time: same format as above}
\PY{l+s+sd}{    Note: we use the Markov Chain formulation: X\PYZus{}\PYZob{}t+1\PYZcb{}|X\PYZus{}t,theta = f(X\PYZus{}t.theta)}
\PY{l+s+sd}{    \PYZdq{}\PYZdq{}\PYZdq{}}
    \PY{c}{\PYZsh{} Container class for graph parameters}
    \PY{n}{n\PYZus{}nodes} \PY{o}{=} \PY{n+nb}{len}\PY{p}{(}\PY{n}{infected}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}
    \PY{n}{theta} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{empty}\PY{p}{(}\PY{p}{(}\PY{n}{n\PYZus{}nodes}\PY{p}{,}\PY{n}{n\PYZus{}nodes}\PY{p}{)}\PY{p}{,} \PY{n}{dtype}\PY{o}{=}\PY{n+nb}{object}\PY{p}{)}
    \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{xrange}\PY{p}{(}\PY{n}{n\PYZus{}nodes}\PY{p}{)}\PY{p}{:}
        \PY{k}{for} \PY{n}{j} \PY{o+ow}{in} \PY{n+nb}{xrange}\PY{p}{(}\PY{n}{n\PYZus{}nodes}\PY{p}{)}\PY{p}{:}
            \PY{k}{if} \PY{n}{prior} \PY{o+ow}{is} \PY{n+nb+bp}{None}\PY{p}{:}
                \PY{n}{theta}\PY{p}{[}\PY{n}{i}\PY{p}{,} \PY{n}{j}\PY{p}{]} \PY{o}{=} \PY{n}{pymc}\PY{o}{.}\PY{n}{Beta}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{theta\PYZus{}\PYZob{}\PYZcb{}\PYZob{}\PYZcb{}}\PY{l+s}{\PYZsq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{i}\PY{p}{,} \PY{n}{j}\PY{p}{)}\PY{p}{,} \PY{n}{alpha}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{,}
                        \PY{n}{beta}\PY{o}{=}\PY{l+m+mi}{1}\PY{p}{)}
            \PY{k}{else}\PY{p}{:}
                \PY{n}{theta}\PY{p}{[}\PY{n}{i}\PY{p}{,} \PY{n}{j}\PY{p}{]} \PY{o}{=} \PY{n}{prior}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{theta\PYZus{}\PYZob{}\PYZcb{}\PYZob{}\PYZcb{}}\PY{l+s}{\PYZsq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{i}\PY{p}{,} \PY{n}{j}\PY{p}{)}\PY{p}{,} \PY{o}{*}\PY{n}{args}\PY{p}{,} \PY{o}{*}\PY{o}{*}\PY{n}{kwargs}\PY{p}{)}

    \PY{c}{\PYZsh{} Container class for cascade realization}
    \PY{n}{x} \PY{o}{=} \PY{p}{\PYZob{}}\PY{p}{\PYZcb{}}
    \PY{k}{for} \PY{n}{i}\PY{p}{,} \PY{n}{cascade} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{infected}\PY{p}{)}\PY{p}{:}
        \PY{k}{for} \PY{n}{j}\PY{p}{,} \PY{n}{step} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{cascade}\PY{p}{)}\PY{p}{:}
            \PY{k}{for} \PY{n}{k}\PY{p}{,} \PY{n}{node} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{step}\PY{p}{)}\PY{p}{:}
                \PY{k}{if} \PY{n}{j} \PY{o+ow}{and} \PY{n}{susceptible}\PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{[}\PY{n}{j}\PY{p}{]}\PY{p}{[}\PY{n}{k}\PY{p}{]}\PY{p}{:}
                    \PY{n}{p} \PY{o}{=} \PY{l+m+mf}{1.} \PY{o}{\PYZhy{}} \PY{n}{pymc}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{cascade}\PY{p}{[}\PY{n}{j}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}\PY{o}{.}\PY{n}{dot}\PY{p}{(}\PY{n}{theta}\PY{p}{[}\PY{n}{k}\PY{p}{]}\PY{p}{)}\PY{p}{)}
                \PY{k}{else}\PY{p}{:}
                    \PY{n}{p} \PY{o}{=} \PY{o}{.}\PY{l+m+mi}{5}
                \PY{n}{x}\PY{p}{[}\PY{n}{i}\PY{p}{,} \PY{n}{j}\PY{p}{,} \PY{n}{k}\PY{p}{]} \PY{o}{=} \PY{n}{pymc}\PY{o}{.}\PY{n}{Bernoulli}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{x\PYZus{}\PYZob{}\PYZcb{}\PYZob{}\PYZcb{}\PYZob{}\PYZcb{}}\PY{l+s}{\PYZsq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{i}\PY{p}{,} \PY{n}{j}\PY{p}{,} \PY{n}{k}\PY{p}{)}\PY{p}{,} \PY{n}{p}\PY{o}{=}\PY{n}{p}\PY{p}{,}
                        \PY{n}{value}\PY{o}{=}\PY{n}{node}\PY{p}{,} \PY{n}{observed}\PY{o}{=}\PY{n+nb+bp}{True}\PY{p}{)}

    \PY{k}{return} \PY{n}{pymc}\PY{o}{.}\PY{n}{Model}\PY{p}{(}\PY{p}{[}\PY{n}{pymc}\PY{o}{.}\PY{n}{Container}\PY{p}{(}\PY{n}{theta}\PY{p}{)}\PY{p}{,} \PY{n}{pymc}\PY{o}{.}\PY{n}{Container}\PY{p}{(}\PY{n}{x}\PY{p}{)}\PY{p}{]}\PY{p}{)}


\PY{k}{if} \PY{n}{\PYZus{}\PYZus{}name\PYZus{}\PYZus{}}\PY{o}{==}\PY{l+s}{\PYZdq{}}\PY{l+s}{\PYZus{}\PYZus{}main\PYZus{}\PYZus{}}\PY{l+s}{\PYZdq{}}\PY{p}{:}
    \PY{k+kn}{import} \PY{n+nn}{main}
    \PY{k+kn}{import} \PY{n+nn}{matplotlib.pyplot} \PY{k+kn}{as} \PY{n+nn}{plt}
    \PY{k+kn}{import} \PY{n+nn}{seaborn}
    \PY{n}{seaborn}\PY{o}{.}\PY{n}{set\PYZus{}style}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{whitegrid}\PY{l+s}{\PYZsq{}}\PY{p}{)}
    \PY{n}{g} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{p}{[}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{]}\PY{p}{,} \PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{]}\PY{p}{,} \PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{]}\PY{p}{,} \PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{1}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{]}\PY{p}{]}\PY{p}{)}
    \PY{n}{p} \PY{o}{=} \PY{l+m+mf}{0.5}
    \PY{n}{g} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{log}\PY{p}{(}\PY{l+m+mf}{1.} \PY{o}{/} \PY{p}{(}\PY{l+m+mi}{1} \PY{o}{\PYZhy{}} \PY{n}{p} \PY{o}{*} \PY{n}{g}\PY{p}{)}\PY{p}{)}

    \PY{k}{print}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{running the graph\PYZhy{}level MC set\PYZhy{}up}\PY{l+s}{\PYZsq{}}\PY{p}{)}
    \PY{n}{cascades} \PY{o}{=} \PY{n}{main}\PY{o}{.}\PY{n}{simulate\PYZus{}cascades}\PY{p}{(}\PY{l+m+mi}{1000}\PY{p}{,} \PY{n}{g}\PY{p}{)}
    \PY{n}{infected}\PY{p}{,} \PY{n}{susc} \PY{o}{=} \PY{n}{main}\PY{o}{.}\PY{n}{build\PYZus{}cascade\PYZus{}list}\PY{p}{(}\PY{n}{cascades}\PY{p}{)}
    \PY{n}{model} \PY{o}{=} \PY{n}{mc\PYZus{}graph\PYZus{}setup}\PY{p}{(}\PY{n}{infected}\PY{p}{,} \PY{n}{susc}\PY{p}{)}
    \PY{n}{mcmc} \PY{o}{=} \PY{n}{pymc}\PY{o}{.}\PY{n}{MCMC}\PY{p}{(}\PY{n}{model}\PY{p}{)}
    \PY{n}{mcmc}\PY{o}{.}\PY{n}{sample}\PY{p}{(}\PY{l+m+mi}{10}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{4}\PY{p}{,} \PY{l+m+mi}{1000}\PY{p}{)}
    \PY{n}{fig}\PY{p}{,} \PY{n}{ax} \PY{o}{=} \PY{n}{plt}\PY{o}{.}\PY{n}{subplots}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{g}\PY{p}{)}\PY{p}{,} \PY{n+nb}{len}\PY{p}{(}\PY{n}{g}\PY{p}{)}\PY{p}{)}
    \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{xrange}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{g}\PY{p}{)}\PY{p}{)}\PY{p}{:}
        \PY{k}{for} \PY{n}{j} \PY{o+ow}{in} \PY{n+nb}{xrange}\PY{p}{(}\PY{n+nb}{len}\PY{p}{(}\PY{n}{g}\PY{p}{)}\PY{p}{)}\PY{p}{:}
            \PY{n}{ax}\PY{p}{[}\PY{n}{i}\PY{p}{,}\PY{n}{j}\PY{p}{]}\PY{o}{.}\PY{n}{locator\PYZus{}params}\PY{p}{(}\PY{n}{nbins}\PY{o}{=}\PY{l+m+mi}{3}\PY{p}{,} \PY{n}{axis}\PY{o}{=}\PY{l+s}{\PYZsq{}}\PY{l+s}{x}\PY{l+s}{\PYZsq{}}\PY{p}{)}
            \PY{n}{ax}\PY{p}{[}\PY{n}{i}\PY{p}{,}\PY{n}{j}\PY{p}{]}\PY{o}{.}\PY{n}{hist}\PY{p}{(}\PY{n}{mcmc}\PY{o}{.}\PY{n}{trace}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{theta\PYZus{}\PYZob{}\PYZcb{}\PYZob{}\PYZcb{}}\PY{l+s}{\PYZsq{}}\PY{o}{.}\PY{n}{format}\PY{p}{(}\PY{n}{i}\PY{p}{,}\PY{n}{j}\PY{p}{)}\PY{p}{)}\PY{p}{[}\PY{p}{:}\PY{p}{]}\PY{p}{,} \PY{n}{normed}\PY{o}{=}\PY{n+nb+bp}{True}\PY{p}{)}
            \PY{n}{ax}\PY{p}{[}\PY{n}{i}\PY{p}{,} \PY{n}{j}\PY{p}{]}\PY{o}{.}\PY{n}{set\PYZus{}xlim}\PY{p}{(}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}
            \PY{n}{ax}\PY{p}{[}\PY{n}{i}\PY{p}{,} \PY{n}{j}\PY{p}{]}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{p}{[}\PY{n}{g}\PY{p}{[}\PY{n}{i}\PY{p}{,} \PY{n}{j}\PY{p}{]}\PY{p}{]}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{,} \PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{ax}\PY{p}{[}\PY{n}{i}\PY{p}{,}\PY{n}{j}\PY{p}{]}\PY{o}{.}\PY{n}{get\PYZus{}ylim}\PY{p}{(}\PY{p}{)}\PY{p}{[}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{]}\PY{p}{,} \PY{n}{color}\PY{o}{=}\PY{l+s}{\PYZsq{}}\PY{l+s}{red}\PY{l+s}{\PYZsq{}}\PY{p}{)}
    \PY{n}{plt}\PY{o}{.}\PY{n}{tight\PYZus{}layout}\PY{p}{(}\PY{n}{pad}\PY{o}{=}\PY{l+m+mf}{0.4}\PY{p}{,} \PY{n}{w\PYZus{}pad}\PY{o}{=}\PY{l+m+mf}{0.5}\PY{p}{,} \PY{n}{h\PYZus{}pad}\PY{o}{=}\PY{o}{.}\PY{l+m+mi}{1}\PY{p}{)}
    \PY{n}{plt}\PY{o}{.}\PY{n}{show}\PY{p}{(}\PY{p}{)}


    \PY{k}{print}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{running the node level set\PYZhy{}up}\PY{l+s}{\PYZsq{}}\PY{p}{)}
    \PY{n}{node} \PY{o}{=} \PY{l+m+mi}{0}
    \PY{n}{cascades} \PY{o}{=} \PY{n}{main}\PY{o}{.}\PY{n}{simulate\PYZus{}cascades}\PY{p}{(}\PY{l+m+mi}{100}\PY{p}{,} \PY{n}{g}\PY{p}{)}
    \PY{n}{cascade}\PY{p}{,} \PY{n}{y\PYZus{}obs} \PY{o}{=} \PY{n}{main}\PY{o}{.}\PY{n}{build\PYZus{}matrix}\PY{p}{(}\PY{n}{cascades}\PY{p}{,} \PY{n}{node}\PY{p}{)}
    \PY{n}{model} \PY{o}{=} \PY{n}{glm\PYZus{}node\PYZus{}setup}\PY{p}{(}\PY{n}{cascade}\PY{p}{,} \PY{n}{y\PYZus{}obs}\PY{p}{)}
    \PY{n}{mcmc} \PY{o}{=} \PY{n}{pymc}\PY{o}{.}\PY{n}{MCMC}\PY{p}{(}\PY{n}{model}\PY{p}{)}
    \PY{n}{mcmc}\PY{o}{.}\PY{n}{sample}\PY{p}{(}\PY{l+m+mf}{1e5}\PY{p}{,} \PY{l+m+mf}{1e4}\PY{p}{)}
    \PY{n}{plt}\PY{o}{.}\PY{n}{hist}\PY{p}{(}\PY{n}{mcmc}\PY{o}{.}\PY{n}{trace}\PY{p}{(}\PY{l+s}{\PYZsq{}}\PY{l+s}{theta\PYZus{}1}\PY{l+s}{\PYZsq{}}\PY{p}{)}\PY{p}{[}\PY{p}{:}\PY{p}{]}\PY{p}{,} \PY{n}{bins}\PY{o}{=}\PY{l+m+mf}{1e2}\PY{p}{)}
    \PY{n}{plt}\PY{o}{.}\PY{n}{show}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
