Hacker News new | ask | show | jobs
by doug1001 3742 days ago
it's not. set aside for a moment the prose description, find an MH module in your language of choice and study the code then play around w/ it in the REPL. A couple of things will probably surprise you when you look at an MCMC implementation (either MH or Gibbs): (i) very compact (eg, MH ~ 40 loc in python; 120 in scala; Gibbs ~10 lines in python, ~40 in scala); and (ii) the primary data structures are ones you probably use every day (eg, 2D array, which is used to represent the transition probabilities among the nodes comprising the graph that models the random walk). (A python/numpy implementation of MH: http://isaacslavitt.com/2013/12/30/metropolis-hastings-and-s...)