ArticleslgStudy

mathematics

Bayesian programming

Bayesian programming is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Bayesian programming rather than just read about it. In short: Bayesian programming is a formalism and a methodology for having a technique to specify probabilistic models and solve problems when less than the necessary information is available. Edwin T.

Bayesian programming — main illustration
Bayesian programming — illustration

Key takeaways

  • Bayesian programming belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Bayesian programming to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Bayesian programming from memory before moving on to harder problems.

Reference excerpt

Bayesian programming is a formalism and a methodology for having a technique to specify probabilistic models and solve problems when less than the necessary information is available. 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 A program is constructed from a description and a question. 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 (δ). A specification is constructed from a set of pertinent variables, a decomposition and a set of forms. Forms are either parametric forms or questions to other Bayesian programs. 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:

Define the set of relevant variables {X1,X2,⋯,XN} on which the joint distribution is defined. Decompose the joint distribution (break it into relevant independent or conditional probabilities). 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.

Example

… excerpt ends here. Continue reading the full article.

Illustrations

Bayesian programming illustration
Bayesian programming illustration

Worked examples

Example 1 — a first encounter with Bayesian programming

Start with the simplest possible case. Write down what Bayesian programming claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Bayesian programming before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Bayesian programming ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Bayesian programming

In research
Bayesian programming appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Bayesian programming in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Bayesian programming is common in secondary-school and first-year university syllabi. It links to neighbouring topics Artificial intelligence, Artificial intelligence engineering, Bayesian statistics, so understanding it makes those chapters shorter.
In everyday life
Look for Bayesian programming outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Bayesian programming” →

How to study Bayesian programming in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Bayesian programming means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Bayesian programming out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Bayesian programming in simple terms?

Bayesian programming is a formalism and a methodology for having a technique to specify probabilistic models and solve problems when less than the necessary information is available. Edwin T.

Why does Bayesian programming matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Bayesian programming?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Bayesian programming.

Tags

  • Artificial intelligence
  • Artificial intelligence engineering
  • Bayesian statistics

Keep exploring