Skip to content

Commit

Permalink
Updated README.rst, removed pair_posterior from Matplot.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Fonnesbeck committed Apr 7, 2012
1 parent 6a90862 commit b8060e2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 147 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ dist/*
pymc.egg-info/
UNKNOWN.egg-info/
docs/_build
MANIFEST
develop
testresults
*.tmproj
*.py.bak
.DS_Store
.DS_Store
31 changes: 16 additions & 15 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Introduction
:Contact: [email protected]
:Web site: http://github.com/pymc-devs/pymc
:Copyright: This document has been placed in the public domain.
:License: PyMC is released under the Academic Free license.
:License: PyMC is released under the Academic Free License.
:Version: 2.2


Expand Down Expand Up @@ -131,22 +131,23 @@ team for PyMC 2.0. This iteration of the software strives for more flexibility,
better performance and a better end-user experience than any previous version
of PyMC.

PyMC 2.2 will be released in early 2012. It contains numerous bugfixes and
optimizations, as well as a few new features. This user guide has been updated
for version 2.2.
PyMC 2.2 was released in April 2012. It contains numerous bugfixes and
optimizations, as well as a few new features, inculding improved output
plotting, csv table output, improved imputation syntax, and posterior
predictive check plots. This user guide has been updated for version 2.2.


Relationship to other packages
==============================

PyMC in one of many general-purpose MCMC packages. The most prominent among
them is `WinBUGS`_, which has made MCMC and with it Bayesian statistics
accessible to a huge user community. Unlike PyMC, WinBUGS is a stand-alone,
self-contained application. This can be an attractive feature for users without
much programming experience, but others may find it constraining. A related
package is `JAGS`_, which provides a more UNIX-like implementation of the BUGS
language. Other packages include `Hierarchical Bayes Compiler`_ and a number of
`R packages`_ of varying scope.
PyMC in one of many general-purpose MCMC packages. The most prominent among
them is `WinBUGS`_, which has made MCMC (and with it, Bayesian statistics)
accessible to a huge user community. Unlike PyMC, WinBUGS is a stand-alone,
self-contained application. This can be an attractive feature for users
without much programming experience, but others may find it constraining. A
related package is `JAGS`_, which provides a more UNIX-like implementation of
the BUGS language. Other packages include `Hierarchical Bayes Compiler`_ and,
more recently, `STAN`_.

It would be difficult to meaningfully benchmark PyMC against these other
packages because of the unlimited variety in Bayesian probability models and
Expand All @@ -167,9 +168,9 @@ required for sampling is often quite reasonable despite this poorer performance.

We have chosen to spend time developing PyMC rather than using an existing
package primarily because it allows us to build and efficiently fit any model
we like within a full-fledged Python environment. We have emphasized
we like within a productuve Python environment. We have emphasized
extensibility throughout PyMC's design, so if it doesn't meet your needs out of
the box chances are you can make it do so with a relatively small amount of
the box, chances are you can make it do so with a relatively small amount of
code. See the `testimonials`_ page on the wiki for reasons why other users have
chosen PyMC.

Expand All @@ -190,7 +191,7 @@ available. More `examples and tutorials`_ are available from the PyMC web site.

.. _`Hierarchical Bayes Compiler`: http://www.cs.utah.edu/~hal/HBC/

.. _`R packages`: http://cran.r-project.org/web/packages/
.. _`STAN`: http://code.google.com/p/stan/

.. _`testimonials`: https://github.com/pymc-devs/pymc/wiki/Testimonials

Expand Down
2 changes: 2 additions & 0 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _chap_tutorial:

********
Tutorial
********
Expand Down
131 changes: 0 additions & 131 deletions pymc/Matplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,137 +733,6 @@ def autocorrelation(data, name, maxlags=100, format='png', suffix='-acf', path='
#close()


# TODO: make sure pair_posterior works.
def pair_posterior(nodes, mask=None, trueval=None, fontsize=8, suffix='', path='./', new=True,
fontmap = None, verbose=1):
"""
pair_posterior(nodes, clear=True, mask=None, trueval=None)
:Arguments:
nodes: An iterable containing stochastic objects with traces.
mask: A dictionary, indexed by stochastic, of boolean-valued
arrays. If mask[p][index]=False, stochastic p's value
at that index will be included in the plot.
trueval: The true values of stochastics (useful for summarizing
performance with simulated data).
Produces a matrix of plots. On the diagonals are the marginal
posteriors of the stochastics, subject to the masks. On the
off-diagonals are the marginal pairwise posteriors of the
stochastics, subject to the masks.
"""

nodes = list(nodes)

if fontmap is None: fontmap = {1:10, 2:8, 3:6, 4:5, 5:4}

if mask is not None:
mask={}
for p in nodes:
mask[p] = None

if trueval is not None:
trueval={}
for p in nodes:
trueval[p] = None

ns = {}
for p in nodes:
if not p.value.shape:
ns[p] = 1
else:
ns[p] = len(p.value.ravel())

index_now = -1
tracelen = {}
ravelledtrace={}
titles={}
indices={}
cum_indices={}


for p in nodes:

tracelen[p] = p.trace().shape[0]
ravelledtrace[p] = p.trace().reshape((tracelen[p],-1))
titles[p]=[]
indices[p] = []
cum_indices[p]=[]

for j in range(ns[p]):
# Should this index be included?
if mask[p]:
if not mask[p].ravel()[j]:
indices[p].append(j)
this_index=True
else:
this_index=False
else:
indices[p].append(j)
this_index=True
# If so:
if this_index:
index_now+=1
cum_indices[p].append(index_now)
# Figure out title string
if ns[p]==1:
titles[p].append(p.__name__)
else:
titles[p].append(p.__name__ + get_index_list(p.value.shape,j).__repr__())

if new:
figure(figsize = (10,10))

n = index_now+1
for p in nodes:
for j in range(len(indices[p])):
# Marginals
ax=subplot(n,n,(cum_indices[p][j])*(n+1)+1)
setp(ax.get_xticklabels(),fontsize=fontsize)
setp(ax.get_yticklabels(),fontsize=fontsize)
hist(ravelledtrace[p][:,j],normed=True,fill=False)
xlabel(titles[p][j],size=fontsize)

# Bivariates
for i in range(len(nodes)-1):
p0 = nodes[i]
for j in range(len(indices[p0])):
p0_i = indices[p0][j]
p0_ci = cum_indices[p0][j]
for k in range(i,len(nodes)):
p1=nodes[k]
if i==k:
l_range = range(j+1,len(indices[p0]))
else:
l_range = range(len(indices[p1]))
for l in l_range:
p1_i = indices[p1][l]
p1_ci = cum_indices[p1][l]
subplot_index = p0_ci*(n) + p1_ci+1
ax=subplot(n, n, subplot_index)
setp(ax.get_xticklabels(),fontsize=fontsize)
setp(ax.get_yticklabels(),fontsize=fontsize)

try:
H, x, y = histogram2d(ravelledtrace[p1][:,p1_i],ravelledtrace[p0][:,p0_i])
contourf(x,y,H,cmap=cm.bone)
except:
print_('Unable to plot histogram for ('+titles[p1][l]+','+titles[p0][j]+'):')
pyplot(ravelledtrace[p1][:,p1_i],ravelledtrace[p0][:,p0_i],'k.',markersize=1.)
axis('tight')

xlabel(titles[p1][l],size=fontsize)
ylabel(titles[p0][j],size=fontsize)

plotname = ''
for obj in nodes:
plotname += obj.__name__ + ''
if not os.path.exists(path):
os.mkdir(path)
if not path.endswith('/'):
path += '/'
savefig("%s%s%s.%s" % (path, plotname, suffix, format))

def zplot(pvalue_dict, name='', format='png', path='./', fontmap = None, verbose=1):
"""Plots absolute values of z-scores for model validation output from
diagnostics.validate()."""
Expand Down

0 comments on commit b8060e2

Please sign in to comment.