Skip to content
 

Interactive visualizations of sampling and GP regression

You really don’t want to miss Chi Feng‘s absolutely wonderful interactive demos.

(1) Markov chain Monte Carlo sampling

I believe this is exactly what Andrew was asking for a few Stan meetings ago:

This tool lets you explore a range of sampling algorithms including random-walk Metropolis, Hamiltonian Monte Carlo, and NUTS operating over a range of two-dimensional distributions (standard normal, banana, donut, multimodal, and one squiggly one). You can control both the settings of the algorithms and the settings of the visualizations. As you run it, it even collects the draws into a sample which it summarizes as marginal histograms.

Source code

The demo is implemented in Javascript with the source code on Chi Feng’s GitHub organization:

Wish list

  1. 3D (glasses or virtual reality headset)
  2. multiple chains in parallel
  3. scatterplot breadcrumbs
  4. Gibbs sampler
  5. Ensemble samplers
  6. User-pluggable densities (Andrew really wants this for Stan where you’d choose two dimensions of N to visualize)

(2) Gaussian Process visualization

This one’s also really elegant.

It lets you lay down a few points and fit a 1D GP. It lets you choose kernel and hperparameters, and even sample regression functions from it conditioned on the data you provide.

Wish list

  1. 3D (OK, I’m obssesed, but this one would be great on a 2D grid with a 3D visualization of a GP being fit)
  2. Estimating hyperparameters (didn’t seem like it was doing this—may be a bit challenging for Javascript!)

Source code

9 Comments

  1. Anonymous says:

    mcmc visualizer is fantastic! it would be great to see two different samplers go head-to-head, eg, RWMH in blue vs. NUTS in red

  2. Umberto says:

    Is it just me or the GP demo doesn’t work right now? (tried with Chrome and Firefox)

    And yes the MCMC demos are stunning!

  3. Duco says:

    Thank you for this post. I was looking to better understand the different algorithms and these demo’s really help!

  4. Richard McElreath says:

    I embedded the MCMC demos into a blog post that tries to explain, without mathematics, why HMC is useful and why NUTS is even better. http://elevanth.org/blog/2017/11/28/build-a-better-markov-chain/

    I hacked the source a bit to make the lines thicker and colors stronger. The code is actually very easy to figure out, in case anyone is thinking of adding new densities or algorithms.

  5. T says:

    Here’s another, similar GP visualization (as mentioned in this blog previously: https://andrewgelman.com/2015/03/07/interactive-demonstrations-linear-gaussian-process-regressions/):
    http://www.tmpl.fi/gp/

    It can also show HMC samples. Source code is at https://github.com/to-mi/gp-demo-js

  6. Aki Vehtari says:

    Another Gaussian process demo with cool animation by Tomi Peltola
    http://www.tmpl.fi/gp/

Leave a Reply