MCMC programming in R, Python, Java and C

3 votes
1386 reads
 

Markov Chain Monte Carlo (MCMC) is a powerful simulation technique for exploring posterior distributions that arise in Bayesian Statistics. In order to do MCMC, you can either use some generic tools including WinBugs and JAGS or you might want to write your own MCMC code in a programing language.

Often times, MCMC algorithms are run through millions of cycles and therefore it's natural to wonder what programming language should be chosen that includes good scientific library on generating random numbers as well as being fast enough to implement MCMC algorithm.

In the post below, Dr. Darren Wilkinson compares MCMC codes under four different languages of R, Python, Java, and C.

He thinks:

"R and Python are slow, on account of their dynamic type systems, but are quick and easy to develop in. Java and C are much faster. The speed advantages of Java and C can be important in the context of complex MCMC algorithms. One possibility that is often put forward is to prototype in a dynamic language like R or Python and then port (the slow parts) to a statically typed language later. This could be time efficient, as the debugging and re-factoring can take place in the dynamic language where it is easier, then just re-coded fairly directly into the statically typed language once the code is working well. Actually, I haven’t found this to be time efficient for the development of MCMC codes. That could be just me, but it could be a feature of MCMC algorithms in that the dynamic code runs too slowly to be amenable to quick and simple debugging."

To read the full article, please click here.