I think I get the general idea of both VI and MCMC including the various flavors of MCMC like Gibbs sampling, Metropolis Hastings etc. This paper provides a wonderful exposition of both methods.

I have the following questions:

  • If I wish to do Bayesian inference, why would I choose one method over the other?
  • What are the pros and cons of each of the methods?

I understand that this is a pretty broad question, but any insights would be highly appreciated.


For a long answer, see Blei, Kucukelbir and McAuliffe here. This short answer draws heavily therefrom.

  • MCMC is asymptotically exact; VI is not. In the limit, MCMC will exactly approximate the target distribution. VI comes without warranty.
  • MCMC is computationally expensive. In general, VI is faster.

Meaning, when we have computational time to kill and value precision of our estimates, MCMC wins. If we can tolerate sacrificing that for expediency—or we're working with data so large we have to make the tradeoff—VI is a natural choice.

Or, as more eloquently and thoroughly described by the authors mentioned above:

Thus, variational inference is suited to large data sets and scenarios where we want to quickly explore many models; MCMC is suited to smaller data sets and scenarios where we happily pay a heavier computational cost for more precise samples. For example, we might use MCMC in a setting where we spent 20 years collecting a small but expensive data set, where we are confident that our model is appropriate, and where we require precise inferences. We might use variational inference when fitting a probabilistic model of text to one billion text documents and where the inferences will be used to serve search results to a large population of users. In this scenario, we can use distributed computation and stochastic optimization to scale and speed up inference, and we can easily explore many different models of the data.

  • 1
    $\begingroup$ I think Stan is the fastest software to do MCMC (NUTS). What's the fastest (or more powerful) to do Variational Inference? $\endgroup$ – skan Nov 22 '18 at 20:45
  • 3
    $\begingroup$ @skan Wonderful question! The closest I've seen to a general-purpose VI software is edward, though I haven't used it myself. (Many applications of VI are custom, in that they derive an algorithm to fit the specific model of interest.) $\endgroup$ – Sean Easter Nov 24 '18 at 13:02
  • 2
    $\begingroup$ Stan also support VI. The only limitation of stan is that it can't sample discrete variables. $\endgroup$ – RJTK Feb 28 '19 at 19:41
  • 2
    $\begingroup$ Also, I don't believe Stan runs ADVI on GPU... yet anyway. The fastest software for variational inference is likely TensorFlow Probability (TFP) or Pyro, both built on highly optimized deep learning frameworks (i.e., CUDA). TFP grew out of early work on Edward by Dustin Tran, who now leads TFP at Google I believe. $\endgroup$ – Adam Erickson Sep 5 '19 at 15:29
  • $\begingroup$ @AdamErickson FYI: Stan gradually starts using GPUs arxiv.org/abs/1907.01063 $\endgroup$ – Tim Nov 25 '19 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.