Variational Bayesian methods are a family of techniques for approximating intractable integrals arising in Bayesian inference and machine learning. They are typically used in complex statistical models consisting of observed variables (usually termed "data") as well as unknown parameters and latent variables, with various sorts of relationships among the three types of random variables, as might be described by a graphical model. As typical in Bayesian inference, the parameters and latent variables are grouped together as "unobserved variables". Variational Bayesian methods are primarily used for two purposes:
To provide an analytical approximation to the posterior probability of the unobserved variables, in order to do statistical inference over these variables. To derive a lower bound for the marginal likelihood (sometimes called the evidence) of the observed data (i.e. the marginal probability of the data given the model, with marginalization performed over unobserved variables). This is typically used for performing model selection, the general idea being that a higher marginal likelihood for a given model indicates a better fit of the data by that model and hence a greater probability that the model in question was the one that generated the data. (See also the Bayes factor article.) In the former purpose (that of approximating a posterior probability), variational Bayes is an alternative to Monte Carlo sampling methods—particularly, Markov chain Monte Carlo methods such as Gibbs sampling—for taking a fully Bayesian approach to statistical inference over complex distributions that are difficult to evaluate directly or sample. In particular, whereas Monte Carlo techniques provide a numerical approximation to the exact posterior using a set of samples, variational Bayes provides a locally-optimal, exact analytical solution to an approximation of the posterior. Variational Bayes can be seen as an extension of the expectation–maximization (EM) algorithm from maximum likelihood (ML) or maximum a posteriori (MAP) estimation of the single most probable value of each parameter to fully Bayesian estimation which computes (an approximation to) the entire posterior distribution of the parameters and latent variables. As in EM, it finds a set of optimal parameter values, and it has the same alternating structure as does EM, based on a set of interlocked (mutually dependent) equations that cannot be solved analytically. For many applications, variational Bayes produces solutions of comparable accuracy to Gibbs sampling at greater speed. However, deriving the set of equations used to update the parameters iteratively often requires a large amount of work compared with deriving the comparable Gibbs sampling equations. This is the case even for many models that are conceptually quite simple, as is demonstrated below in the case of a basic non-hierarchical model with only two parameters and no latent variables.
Mathematical derivation
Problem In variational inference, the posterior distribution over a set of unobserved variables Z = { Z 1 … Z n } {\displaystyle \mathbf {Z} =\{Z_{1}\dots Z_{n}\}} given some data X {\displaystyle \mathbf {X} } is approximated by a so-called variational distribution, Q ( Z ) : {\displaystyle Q(\mathbf {Z} ):}
P ( Z ∣ X ) ≈ Q ( Z ) . {\displaystyle P(\mathbf {Z} \mid \mathbf {X} )\approx Q(\mathbf {Z} ).}
The distribution Q ( Z ) {\displaystyle Q(\mathbf {Z} )} is restricted to belong to a family of distributions of simpler form than P ( Z ∣ X ) {\displaystyle P(\mathbf {Z} \mid \mathbf {X} )} (e.g. a family of Gaussian distributions), selected with the intention of making Q ( Z ) {\displaystyle Q(\mathbf {Z} )} similar to the true posterior, P ( Z ∣ X ) {\displaystyle P(\mathbf {Z} \mid \mathbf {X} )} . The similarity (or dissimilarity) is measured in terms of a dissimilarity function d ( Q ; P ) {\displaystyle d(Q;P)} and hence inference is performed by selecting the distribution Q ( Z ) {\displaystyle Q(\mathbf {Z} )} that minimizes d ( Q ; P ) {\displaystyle d(Q;P)} .
KL divergence The most common type of variational Bayes uses the Kullback–Leibler divergence (KL-divergence) of Q from P as the choice of dissimilarity function. This choice makes this minimization tractable. The KL-divergence is defined as
D K L ( Q ∥ P ) ≜ ∑ Z Q ( Z ) log Q ( Z ) P ( Z ∣ X ) . {\displaystyle D_{\mathrm {KL} }(Q\parallel P)\triangleq \sum _{\mathbf {Z} }Q(\mathbf {Z} )\log {\frac {Q(\mathbf {Z} )}{P(\mathbf {Z} \mid \mathbf {X} )}}.}
… excerpt ends here. Continue reading the full article.

![Variational Bayesian methods: Generalized Pythagorean theorem for Bregman divergence[2]](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/Bregman_divergence_Pythagorean.png/500px-Bregman_divergence_Pythagorean.png?utm_source=en.wikipedia.org&utm_campaign=parser&utm_content=thumbnail)
![Variational Bayesian methods: Pictorial illustration of coordinate ascent variational inference algorithm by the duality formula[4]](https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/CAVI_algorithm_explain.jpg/1280px-CAVI_algorithm_explain.jpg?utm_source=en.wikipedia.org&utm_campaign=parser&utm_content=thumbnail)
![Variational Bayesian methods: Bayesian Gaussian mixture model using plate notation. Smaller squares indicate fixed parameters; larger circles indicate random variables. Filled-in shapes indicate known values. The indication [K] means a vector of size K; [D,D] means a matrix of size D×D; K alone means a categorical variable with K outcomes. The squiggly line coming from z ending in a crossbar indicates a switch — the value of this variable selects, for the other incoming variables, which value to use out of the size-K array of possible values.](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Bayesian-gaussian-mixture-vb.svg/960px-Bayesian-gaussian-mixture-vb.svg.png?utm_source=en.wikipedia.org&utm_campaign=parser&utm_content=thumbnail)
