in statistics and in statistical physics, gibbs sampling or a gibbs sampler is a markov chain monte carlo (mcmc) algorithm for obtaining a sequence of observations which are approximated from a specified multivariate probability distribution (i.e. from the joint probability distribution of two or more random variables), when direct sampling is difficult. this sequence can be used to approximate the joint distribution (e.g., to generate a histogram of the distribution); to approximate the marginal distribution of one of the variables, or some subset of the variables (for example, the unknown parameters or latent variables); or to compute an integral (such as the expected value of one of the variables). typically, some of the variables correspond to observations whose values are known, and hence do not need to be sampled. gibbs sampling is commonly used as a means of statistical inference, especially bayesian inference. it is a randomized algorithm (i.e. an algorithm that makes use of random numbers, and hence may produce different results each time it is run), and is an alternative to deterministic algorithms for statistical inference such as variational bayes or the expectation-maximization algorithm (em). as with other mcmc algorithms, gibbs sampling generates a markov chain of samples, each of which is correlated with nearby samples. as a result, care must be taken if independent samples are desired (typically by thinning the resulting chain of samples by only taking every nth value, e.g. every 100th value). in addition (again, as in other mcmc algorithms), samples from the beginning of the chain (the burn-in period) may not accurately represent the desired distribution. ==introduction== gibbs sampling is named after the physicist josiah willard gibbs, in reference to an analogy between the sampling algorithm and statistical physics. the algorithm was described by brothers stuart and donald geman in 1984, some eight decades after the death of gibbs. in its basic version, gibbs sampling is a special case of the metropolisâhastings algorithm. however, in its extended versions (see below), it can be considered a general framework for sampling from a large set of variables by sampling each variable (or in some cases, each group of variables) in turn, and can incorporate the [[me
Markov_chain_Monte_Carlo