Electronic Journal of Statistics

Exact sampling for intractable probability distributions via a Bernoulli factory

James M. Flegal and Radu Herbei

Full-text: Open access


Many applications in the field of statistics require Markov chain Monte Carlo methods. Determining appropriate starting values and run lengths can be both analytically and empirically challenging. A desire to overcome these problems has led to the development of exact, or perfect, sampling algorithms which convert a Markov chain into an algorithm that produces i.i.d. samples from the stationary distribution. Unfortunately, very few of these algorithms have been developed for the distributions that arise in statistical applications, which typically have uncountable support. Here we study an exact sampling algorithm using a geometrically ergodic Markov chain on a general state space. Our work provides a significant reduction to the number of input draws necessary for the Bernoulli factory, which enables exact sampling via a rejection sampling approach. We illustrate the algorithm on a univariate Metropolis-Hastings sampler and a bivariate Gibbs sampler, which provide a proof of concept and insight into hyper-parameter selection. Finally, we illustrate the algorithm on a Bayesian version of the one-way random effects model with data from a styrene exposure study.

Article information

Electron. J. Statist., Volume 6 (2012), 10-37.

First available in Project Euclid: 25 January 2012

Permanent link to this document

Digital Object Identifier

Mathematical Reviews number (MathSciNet)

Zentralblatt MATH identifier

Primary: 60J22: Computational methods in Markov chains [See also 65C40]

Markov chain Monte Carlo perfect sampling Bernoulli factory geometric ergodicity


Flegal, James M.; Herbei, Radu. Exact sampling for intractable probability distributions via a Bernoulli factory. Electron. J. Statist. 6 (2012), 10--37. doi:10.1214/11-EJS663. https://projecteuclid.org/euclid.ejs/1327505821

Export citation


  • Asmussen, S., Glynn, P. W., and Thorisson, H. (1992). Stationarity detection in the initial transient problem., ACM Trans. Model. Comput. Simul., 2:130–157.
  • Blanchet, J. and Meng, X.-L. (2005). Exact sampling, regeneration and minorization conditions. Technical report, Columbia University. Available at:, http://www.columbia.edu/~jb2814/papers/JSMsent.pdf.
  • Blanchet, J. and Thomas, A. C. (2007). Exact simulation and error-controlled sampling via regeneration and a Bernoulli factory. Technical report, Harvard University. Available at:, http://www.acthomas.ca/papers/factory-sampling.pdf.
  • Chen, M.-H., Shao, Q.-M., and Ibrahim, J. G. (2000)., Monte Carlo Methods in Bayesian Computation. Springer-Verlag Inc.
  • Craiu, R. V. and Meng, X.-L. (2011). Perfection with research: Exact MCMC sampling. In Brooks, S., Gelman, A., Jones, G., and Meng, X., editors, Handbook of Markov Chain Monte Carlo, pages 199–225. Chapman & Hall/CRC Press.
  • Fill, J. A. (1998). An interruptible algorithm for perfect sampling via Markov chains., Annals of Applied Probability, 8:131–162.
  • Flegal, J. M., Haran, M., and Jones, G. L. (2008). Markov chain Monte Carlo: Can we trust the third significant figure?, Statistical Science, 23:250–260.
  • Flegal, J. M. and Jones, G. L. (2010). Batch means and spectral variance estimators in Markov chain Monte Carlo., The Annals of Statistics, 38:1034–1070.
  • Green, P. J. and Murdoch, D. J. (1999). Exact sampling for Bayesian inference: Towards general purpose algorithms. In Berger, J. O., Bernardo, J. M., Dawid, A. P., Lindley, D. V., and Smith, A. F. M., editors, Bayesian Statistics 6, pages 302–321, Oxford. Oxford University Press.
  • Hobert, J. P. and Geyer, C. J. (1998). Geometric ergodicity of Gibbs and block Gibbs samplers for a hierarchical random effects model., Journal of Multivariate Analysis, 67:414–430.
  • Hobert, J. P., Jones, G. L., Presnell, B., and Rosenthal, J. S. (2002). On the applicability of regenerative simulation in Markov chain Monte Carlo., Biometrika, 89:731–743.
  • Hobert, J. P., Jones, G. L., and Robert, C. P. (2006). Using a Markov chain to construct a tractable approximation of an intractable probability distribution., Scandinavian Journal of Statistics, 33(1):37–51.
  • Hobert, J. P. and Robert, C. P. (2004). A mixture representation of, π with applications in Markov chain Monte Carlo and perfect sampling. Ann. Appl. Probab., 14:1295–1305.
  • Huber, M. (2004). Perfect sampling using bounding chains., The Annals of Applied Probability, 14(2):734–753.
  • Jones, G. L. and Hobert, J. P. (2001). Honest exploration of intractable probability distributions via Markov chain Monte Carlo., Statistical Science, 16:312–334.
  • Jones, G. L. and Hobert, J. P. (2004). Sufficient burn-in for Gibbs samplers for a hierarchical random effects model., The Annals of Statistics, 32:784–817.
  • Keane, M. S. and O’Brien, G. (1994). A Bernoulli factory., ACM Transactions on Modeling and Computer Simulation, 2:213–219.
  • Latuszynski, K., Kosmidis, I., Papaspiliopoulos, O., and Roberts, G. O. (2011). Simulating events of unknown probabilities via reverse time martingales., Random Structures & Algorithms, 38(4):441–452.
  • Liu, J. S. (2001)., Monte Carlo Strategies in Scientific Computing. Springer, New York.
  • Lund, R. B. and Tweedie, R. L. (1996). Geometric convergence rates for stochastically ordered Markov chains., Mathematics of Operations Research, 20:182–194.
  • Lyles, R. H., Kupper, L. L., and Rappaport, S. M. (1997). Assessing regulatory compliance of occupational exposures via the balanced one-way random effects ANOVA model., Journal of Agricultural, Biological, and Environmental Statistics, 2:64–86.
  • Meyn, S. P. and Tweedie, R. L. (1993)., Markov Chains and Stochastic Stability. Springer-Verlag, London.
  • Murdoch, D. J. and Green, P. J. (1998). Exact sampling from a continuous state space., Scandinavian Journal of Statistics, 25:483–502.
  • Mykland, P., Tierney, L., and Yu, B. (1995). Regeneration in Markov chain samplers., Journal of the American Statistical Association, 90:233–241.
  • Nacu, Ş. and Peres, Y. (2005). Fast simulation of new coins from old., Annals of Applied Probability, 15:93–115.
  • Nummelin, E. (1984)., General Irreducible Markov Chains and Non-negative Operators. Cambridge University Press, London.
  • Propp, J. G. and Wilson, D. B. (1996). Exact sampling with coupled Markov chains and applications to statistical mechanics., Random Structures and Algorithms, 9:223–252.
  • Robert, C. P. and Casella, G. (1999)., Monte Carlo Statistical Methods. Springer, New York.
  • Roberts, G. O. and Rosenthal, J. S. (2004). General state space Markov chains and MCMC algorithms., Probability Surveys, 1:20–71.
  • Roberts, G. O. and Tweedie, R. L. (1999). Bounds on regeneration times and convergence rates for Markov chains., Stochastic Processes and their Applications, 80:211–229. Corrigendum (2001) 91:337-338.
  • Roberts, G. O. and Tweedie, R. L. (2001). Corrigendum to “Bounds on regeneration times and convergence rates for Markov chains”., Stochastic Processes and their Applications, 91:337–338.
  • Rosenthal, J. S. (1995). Minorization conditions and convergence rates for Markov chain Monte Carlo., Journal of the American Statistical Association, 90:558–566.
  • Rosenthal, J. S. (1996). Analysis of the Gibbs sampler for a model related to James-Stein estimators., Statistics and Computing, 6:269–275.
  • Rosenthal, J. S. (2002). Quantitative convergence rates of Markov chains: A simple account., Electronic Communications of Probability, 7:123–128.
  • Roy, V. and Hobert, J. P. (2007). Convergence rates and asymptotic standard errors for Markov chain Monte Carlo algorithms for Bayesian probit regression., Journal of the Royal Statistical Society, Series B, 69(4):607–623.
  • Tan, A. and Hobert, J. P. (2009). Block Gibbs sampling for Bayesian random effects models with improper priors: Convergence and regeneration., Journal of Computational and Graphical Statistics, 18:861–878.
  • van Dyk, D. A. and Meng, X.-L. (2001). The art of data augmentation (with discussion)., Journal of Computational and Graphical Statistics, 10:1–50.
  • Wilson, D. B. (2000). How to couple from the past using a read-once source of randomness., Random Structures and Algorithms, 16:85–113.