Jonathan Sedar - Hierarchical Bayesian Modelling with PyMC3 and PySTAN

pystan

#1

There’s a talk that I don’t think has been posted here about PyMC3 and PyStan. I think the majority of it is a comparison of the two, including slides like this:

His presentation of the models in PyMC3 vs PyStan makes me think we really should add vectorized comparisons soon (and maybe a dictionary type?) soon.


#2

This does seem like a call for more postprocessing and analysis tools in Python. It would seem like it would behoove us to combine forces with PyMC3 and maybe others to write a definitive coda-like pacakge. The problem is the seams between the samplers/packages and something like Coda (that’s Martyn Plummer’s R package to do posterior analysis—we like the algorithms in ours better, but Martyn was designed to be standalone).

I have no idea what they mean by “pythonic docs”. They are probably referring to the PDF manual for the language, because PyStan itself is documented like every other Python package I’ve ever seen on readthedocs.

PyMC3 doesn’t let you just plug in arbitrary Python. If someone implements a density in some Python package, you can’t just plug it into PyMC3. If you want something that plays with the density, you need to add derivatives or you need to write it using Theano functions. See:

http://docs.pymc.io/notebooks/getting_started.html#Arbitrary-distributions

on how to use Theano (not arbitrary PyMC3) and here on how to extend Theano if the operations aren’t available:

http://docs.pymc.io/advanced_theano.html

It’s basically the same as Stan’s C++; you can write in the language if the primitives you need are defined, otherwise you have to extend it.

I think they put Metropolis-Hastings and slice sampling on the wrong side of the chart.

Both PyMC3 and Stan are “fiscally sponsored projects” of NumFOCUS (though it’s hard to say who’s supporting whom here financially as they take overhead).

Someone needs to compare efficiency, which is complicated by Theano’s configuration and GPU support and our vectorization, etc.

You might want to add that we have richer data types and many more functions implemented than PyMC3. For instance, we have ODE solvers, algebraic solvers, a gazillion vectorized densities, etc. All that would be straightforward, but time consuming, to add to PyMC3.

We also have a lot more example models floating around the web for all sorts of applications.

One of the big differences is that we tend to assume our users are applied statisticians whereas PyMC3 assumes its users are Python programmers.


#3

tagging @kon - We started talking about general differences between PyStan and PyMC3 here.


#4

Thanks @seantalts - that’s helpful.
I came across yet another recent reference that seems very comprehensive -
http://mattpitkin.github.io/samplers-demo/pages/samplers-samplers-everywhere/


#5

This is more of a Rosetta Stone of Hello Worlds, not a speed comparison. It’s a simple model, again run at all default settings and not compared in terms of sampling efficiency, only wall time.