Lably
Skip to content

Bayesian programming

Statistics concept

  • 11 min read
  • 5 chapters

Related on Lably

Through Probability distribution, Random variable and Independence (probability theory)

Edwin T. Jaynes proposed that probability could be considered as an alternative and an extension of logic for rational reasoning with incomplete and uncertain information. In his founding book Probability Theory: The Logic of Science he developed this theory and proposed what he called "the robot," which was not a physical device, but an inference engine to automate probabilistic reasoning—a kind of Prolog for probability instead of logic. Bayesian programming is a formal and concrete implementation of this "robot".

Bayesian programming may also be seen as an algebraic formalism to specify graphical models such as, for instance, Bayesian networks, dynamic Bayesian networks, Kalman filters or hidden Markov models. Indeed, Bayesian programming is more general than Bayesian networks and has a power of expression equivalent to probabilistic factor graphs.

Formalism

A Bayesian program is a means of specifying a family of probability distributions.

The constituent elements of a Bayesian program are presented below:

Program{Description{Specification(π){VariablesDecompositionFormsIdentification (based on δ)Question
  1. A program is constructed from a description and a question.
  2. A description is constructed using some specification (π) as given by the programmer and an identification or learning process for the parameters not completely specified by the specification, using a data set (δ).
  3. A specification is constructed from a set of pertinent variables, a decomposition and a set of forms.
  4. Forms are either parametric forms or questions to other Bayesian programs.
  5. A question specifies which probability distribution has to be computed.

Description

The purpose of a description is to specify an effective method of computing a joint probability distribution on a set of variables {X1,X2,⋯,XN} given a set of experimental data δ and some specification π. This joint distribution is denoted as: P(X1∧X2∧⋯∧XN∣δ∧π).

To specify preliminary knowledge π, the programmer must undertake the following:

  1. Define the set of relevant variables {X1,X2,⋯,XN} on which the joint distribution is defined.
  2. Decompose the joint distribution (break it into relevant independent or conditional probabilities).
  3. Define the forms of each of the distributions (e.g., for each variable, one of the list of probability distributions).

Decomposition

Given a partition of {X1,X2,…,XN} containing K subsets, K variables are defined L1,⋯,LK, each corresponding to one of these subsets. Each variable Lk is obtained as the conjunction of the variables {Xk1,Xk2,⋯} belonging to the kth subset. Recursive application of Bayes' theorem leads to:

P(X1∧X2∧⋯∧XN∣δ∧π)=P(L1∧⋯∧LK∣δ∧π)=P(L1∣δ∧π)×P(L2∣L1∧δ∧π)×⋯×P(LK∣LK−1∧⋯∧L1∧δ∧π)

Conditional independence hypotheses then allow further simplifications. A conditional independence hypothesis for variable Lk is defined by choosing some variable Xn among the variables appearing in the conjunction Lk−1∧⋯∧L2∧L1, labelling Rk as the conjunction of these chosen variables and setting:

P(Lk∣Lk−1∧⋯∧L1∧δ∧π)=P(Lk∣Rk∧δ∧π)

We then obtain:

P(X1∧X2∧⋯∧XN∣δ∧π)=P(L1∣δ∧π)×P(L2∣R2∧δ∧π)×⋯×P(LK∣RK∧δ∧π)

Such a simplification of the joint distribution as a product of simpler distributions is called a decomposition, derived using the chain rule.

This ensures that each variable appears at the most once on the left of a conditioning bar, which is the necessary and sufficient condition to write mathematically valid decompositions.

Forms

Each distribution P(Lk∣Rk∧δ∧π) appearing in the product is then associated with either a parametric form (i.e., a function fμ(Lk)) or a question to another Bayesian program P(Lk∣Rk∧δ∧π)=P(L∣R∧δ^∧π^).

When it is a form fμ(Lk), in general, μ is a vector of parameters that may depend on Rk or δ or both. Learning takes place when some of these parameters are computed using the data set δ.

An important feature of Bayesian programming is this capacity to use questions to other Bayesian programs as components of the definition of a new Bayesian program. P(Lk∣Rk∧δ∧π) is obtained by some inferences done by another Bayesian program defined by the specifications π^ and the data δ^. This is similar to calling a subroutine in classical programming and provides an easy way to build hierarchical models.

Question

Given a description (i.e., P(X1∧X2∧⋯∧XN∣δ∧π)), a question is obtained by partitioning {X1,X2,⋯,XN} into three sets: the searched variables, the known variables and the free variables.

The 3 variables Searched, Known and Free are defined as the conjunction of the variables belonging to these sets.

A question is defined as the set of distributions:

P(Searched∣Known∧δ∧π)

made of many "instantiated questions" as the cardinal of Known, each instantiated question being the distribution:

P(Searched∣Known∧δ∧π)

Inference

Given the joint distribution P(X1∧X2∧⋯∧XN∣δ∧π), it is always possible to compute any possible question using the following general inference:

P(Searched∣Known∧δ∧π)=∑Free[P(Searched∧Free∣Known∧δ∧π)]=∑Free[P(Searched∧Free∧Known∣δ∧π)]P(Known∣δ∧π)=∑Free[P(Searched∧Free∧Known∣δ∧π)]∑Free∧Searched[P(Searched∧Free∧Known∣δ∧π)]=1Z×∑Free[P(Searched∧Free∧Known∣δ∧π)]

where the first equality results from the marginalization rule, the second results from Bayes' theorem and the third corresponds to a second application of marginalization. The denominator appears to be a normalization term and can be replaced by a constant Z.

Theoretically, this allows to solve any Bayesian inference problem. In practice, however, the cost of computing exhaustively and exactly P(Searched∣Known∧δ∧π) is too great in almost all cases.

Replacing the joint distribution by its decomposition we get:

P(Searched∣Known∧δ∧π)=1Z∑Free[∏k=1K[P(Li∣Ki∧π)]]

which is usually a much simpler expression to compute, as the dimensionality of the problem is considerably reduced by the decomposition into a product of lower dimension distributions.

Sign in to keep reading

4 more chapters are free with a Lably account.

More in Statistics