encyclopegia.org

Bayesian programming

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.

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. ={} & P\left(L_{1}\wedge\cdots\wedge L_{K}\mid\delta\wedge\pi\right)\\ ={} & P\left(L_{1}\mid\delta\wedge\pi\right)\times P\left(L_{2}\mid R_{2}\wedge\delta\wedge\pi\right)\times\cdots\times P\left(L_{K}\mid R_{K}\wedge\delta\wedge\pi\right)\end{align} 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. with either a parametric form (i.e., a function f_{\mu}\left(L_{k}\right) ) or a question to another Bayesian program P\left(L_{k}\mid R_{k} \wedge \delta \wedge \pi \right) = P\left(L\mid R\wedge\widehat{\delta}\wedge\widehat{\pi}\right) . When it is a form f_{\mu}\left(L_{k}\right) , in general, \mu is a vector of parameters that may depend on R_{k} or \delta or both. Learning takes place when some of these parameters are computed using the data set \delta . 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\left(L_{k}\mid R_{k}\wedge\delta\wedge\pi\right) is obtained by some inferences done by another Bayesian program defined by the specifications \widehat{\pi} and the data \widehat{\delta} . This is similar to calling a subroutine in classical programming and provides an easy way to build hierarchical models. ={} & \sum_\text{Free}\left[P\left( \text{Searched} \wedge \text{Free} \mid \text{Known}\wedge\delta\wedge\pi\right)\right]\\ ={} & \frac{\displaystyle \sum_\text{Free}\left[P\left(\text{Searched}\wedge \text{Free}\wedge \text{Known}\mid\delta\wedge\pi\right)\right]}{\displaystyle P\left(\text{Known}\mid\delta\wedge\pi\right)}\\ ={} & \frac{\displaystyle \sum_\text{Free}\left[P\left(\text{Searched}\wedge \text{Free}\wedge \text{Known}\mid\delta\wedge\pi\right)\right]}{\displaystyle \sum_{\text{Free}\wedge \text{Searched}} \left[P\left(\text{Searched} \wedge \text{Free} \wedge \text{Known}\mid\delta\wedge\pi\right)\right]}\\ ={} & \frac{1}{Z}\times\sum_\text{Free}\left[P\left(\text{Searched}\wedge \text{Free} \wedge \text{Known} \mid \delta\wedge\pi\right)\right]\end{align} 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\left(\text{Searched} \mid \text{Known} \wedge\delta\wedge\pi\right) is too great in almost all cases. Replacing the joint distribution by its decomposition we get: \begin{align} & P\left(\text{Searched}\mid \text{Known}\wedge\delta\wedge\pi\right)\\ = {}& \frac{1}{Z} \sum_\text{Free} \left[\prod_{k=1}^K \left[ P\left( L_{i}\mid K_{i} \wedge \pi \right)\right]\right] \end{align} 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. ===Bayesian spam detection=== The purpose of Bayesian spam filtering is to eliminate junk e-mails. The problem is very easy to formulate. E-mails should be classified into one of two categories: non-spam or spam. The only available information to classify the e-mails is their content: a set of words. Using these words without taking the order into account is commonly called a bag of words model. The classifier should furthermore be able to adapt to its user and to learn from experience. Starting from an initial standard setting, the classifier should modify its internal parameters when the user disagrees with its own decision. It will hence adapt to the user's criteria to differentiate between non-spam and spam. It will improve its results as it encounters increasingly classified e-mails. \land W_{N-1}) = P(\text{Spam})\prod_{n=0}^{N-1}[P(W_n\mid\text{Spam})] This kind of assumption is known as the naive Bayes' assumption. It is "naive" in the sense that the independence between words is clearly not completely true. For instance, it completely neglects that the appearance of pairs of words may be more significant than isolated appearances. However, the programmer may assume this hypothesis and may develop the model and the associated inferences to test how reliable and efficient it is. P(\text{Spam}) is a prior defined, for instance, by P([\text{Spam}=1]) = 0.75 Each of the N forms P(W_n\mid\text{Spam}) may be specified using Laplace rule of succession (this is a pseudocounts-based smoothing technique to counter the zero-frequency problem of words never-seen-before): P(W_n\mid[\text{Spam}=\text{false}])=\frac{1+a^n_f}{2+a_f} P(W_n\mid[\text{Spam}=\text{true}])=\frac{1+a^n_t}{2+a_t} where a^n_f stands for the number of appearances of the n^{th} word in non-spam e-mails and a_f stands for the total number of non-spam e-mails. Similarly, a_t^n stands for the number of appearances of the n^{th} word in spam e-mails and a_t stands for the total number of spam e-mails. The N forms P(W_n\mid\text{Spam}) are not yet completely specified because the 2N + 2 parameters a_f^{n=0, \ldots, N-1} , a_t^{n=0, \ldots, N-1} , a_f and a_t have no values yet. The identification of these parameters could be done either by batch processing a series of classified e-mails or by an incremental updating of the parameters using the user's classifications of the e-mails as they arrive. Both methods could be combined: the system could start with initial standard values of these parameters issued from a generic database, then some incremental learning customizes the classifier to each individual user. ={} & \frac{\displaystyle P(\text{Spam}) \prod_{n=0}^{N-1} [ P(w_{n}\mid\text{Spam})]}{\displaystyle \sum_\text{Spam} [P(\text{Spam}) \prod_{n=0}^{N-1} [P (w_{n}\mid\text{Spam}) }\end{align} The denominator appears to be a normalization constant. It is not necessary to compute it to decide if we are dealing with spam. For instance, an easy trick is to compute the ratio: \begin{align} & \frac{P([\text{Spam}=\text{true}]\mid w_0\wedge\cdots\wedge w_{N-1})}{P([ \text{Spam} = \text{false} ]\mid w_0 \wedge\cdots\wedge w_{N-1})}\\ ={} & \frac{P([ \text{Spam}=\text{true} ] )}{P([ \text{Spam} =\text{false} ])}\times\prod_{n=0}^{N-1} \left[\frac{P(w_n\mid [\text{Spam}=\text{true}])}{P(w_n\mid [\text{Spam} = \text{false}])}\right] \end{align} This computation is faster and easier because it requires only 2N products. = P(\text{Spam})\prod_{n=0}^{N-1}P(W_n\mid\text{Spam}) \end{cases}\\ Fo: \begin{cases} P(\text{Spam}): \begin{cases} P([\text{Spam}=\text{false}])=0.25 \\ P([\text{Spam}=\text{true}])=0.75 \end{cases}\\ P(W_n\mid\text{Spam}): \begin{cases} P(W_n\mid[\text{Spam}=\text{false}])\\ =\frac{1+a^n_f}{2+a_f} \\ P(W_n\mid[\text{Spam}=\text{true}])\\ =\frac{1+a^n_t}{2+a_t} \end{cases} \\ \end{cases}\\ \end{cases}\\ \text{Identification (based on }\delta) \end{cases}\\ Qu: P(\text{Spam}\mid w_0 \land \ldots \land w_n \land \ldots \land w_{N-1}) \end{cases} ===Bayesian filter, Kalman filter and hidden Markov model=== Bayesian filters (often called Recursive Bayesian estimation) are generic probabilistic models for time evolving processes. Numerous models are particular instances of this generic approach, for instance: the Kalman filter or the Hidden Markov model (HMM). The most common case is Bayesian filtering where k=0 , which searches for the present state, knowing past observations. However, it is also possible (k>0) , to extrapolate a future state from past observations, or to do smoothing (k , to recover a past state from observations made either before or after that instant. More complicated questions may also be asked as shown below in the HMM section. Bayesian filters (k=0) have a very interesting recursive property, which contributes greatly to their attractiveness. P\left(S^{t}|O^{0}\wedge\cdots\wedge O^{t}\right) may be computed simply from P\left(S^{t-1}\mid O^0 \wedge \cdots \wedge O^{t-1}\right) with the following formula: \begin{array}{ll} & P\left(S^{t}|O^{0}\wedge\cdots\wedge O^{t}\right)\\ = & P\left(O^{t}|S^{t}\right)\times\sum_{S^{t-1}}\left[P\left(S^{t}|S^{t-1}\right)\times P\left(S^{t-1}|O^{0}\wedge\cdots\wedge O^{t-1}\right)\right]\end{array} Another interesting point of view for this equation is to consider that there are two phases: a prediction phase and an estimation phase: During the prediction phase, the state is predicted using the dynamic model and the estimation of the state at the previous moment: \begin{array}{ll} & P\left(S^{t}|O^{0}\wedge\cdots\wedge O^{t-1}\right)\\ = & \sum_{S^{t-1}}\left[P\left(S^{t}|S^{t-1}\right)\times P\left(S^{t-1}|O^{0}\wedge\cdots\wedge O^{t-1}\right)\right]\end{array} During the estimation phase, the prediction is either confirmed or invalidated using the last observation: \begin{align} & P\left(S^{t}\mid O^{0}\wedge\cdots\wedge O^{t}\right)\\ ={} & P\left(O^{t}\mid S^{t}\right)\times P\left(S^{t}|O^{0}\wedge\cdots\wedge O^{t-1}\right) \end{align} = & P\left(S^{0}\wedge O^{0}\right)\times\prod_{t=1}^{T}\left[P\left(S^{t}|S^{t-1}\right)\times P\left(O^{t}|S^{t}\right)\right]\end{cases}\\ Fo:\\ \begin{cases} P\left(S^{0}\wedge O^{0}\right)\\ P\left(S^{t}|S^{t-1}\right)\\ P\left(O^{t}|S^{t}\right)\end{cases}\end{cases}\\ Id\end{cases}\\ Qu:\\ \begin{cases} \begin{array}{l} P\left(S^{t+k}|O^{0}\wedge\cdots\wedge O^{t}\right)\\ \left(k=0\right)\equiv \text{Filtering} \\ \left(k>0\right)\equiv \text{Prediction} \\ \left(k ====Kalman filter==== The very well-known Kalman filters are a special case of Bayesian filters. They are defined by the following Bayesian program: Pr\begin{cases} Ds\begin{cases} Sp(\pi)\begin{cases} Va:\\ S^{0},\cdots,S^{T},O^{0},\cdots,O^{T}\\ Dc:\\ \begin{cases} & P\left(S^{0}\wedge\cdots\wedge O^{T}|\pi\right)\\ = & \left[\begin{array}{c} P\left(S^{0}\wedge O^{0}|\pi\right)\\ \prod_{t=1}^{T}\left[P\left(S^{t}|S^{t-1}\wedge\pi\right)\times P\left(O^{t}|S^{t}\wedge\pi\right)\right]\end{array}\right]\end{cases}\\ Fo:\\ \begin{cases} P\left(S^t \mid S^{t-1}\wedge\pi\right)\equiv G\left(S^{t},A\bullet S^{t-1},Q\right)\\ P\left(O^t \mid S^t \wedge\pi\right)\equiv G\left(O^{t},H\bullet S^{t},R\right)\end{cases}\end{cases}\\ Id\end{cases}\\ Qu:\\ P\left(S^T \mid O^0 \wedge\cdots\wedge O^{T}\wedge\pi\right)\end{cases} Variables are continuous. The transition model P(S^t \mid S^{t-1}\wedge\pi) and the observation model P(O^t \mid S^t \wedge\pi) are both specified using Gaussian laws with means that are linear functions of the conditioning variables. With these hypotheses and by using the recursive formula, it is possible to solve the inference problem analytically to answer the usual P(S^T \mid O^0 \wedge\cdots\wedge O^T \wedge\pi) question. This leads to an extremely efficient algorithm, which explains the popularity of Kalman filters and the number of their everyday applications. When there are no obvious linear transition and observation models, it is still often possible, using a first-order Taylor's expansion, to treat these models as locally linear. This generalization is commonly called the extended Kalman filter. ====Hidden Markov model==== Hidden Markov models (HMMs) are another very popular specialization of Bayesian filters. They are defined by the following Bayesian program: \Pr\begin{cases} Ds\begin{cases} Sp(\pi)\begin{cases} Va:\\ S^{0},\ldots,S^{T},O^{0},\ldots,O^{T}\\ Dc:\\ \begin{cases} & P\left(S^{0}\wedge\cdots\wedge O^{T}\mid\pi\right)\\ = & \left[\begin{array}{c} P\left(S^{0}\wedge O^{0}\mid\pi\right)\\ \prod_{t=1}^{T}\left[P\left(S^{t}\mid S^{t-1}\wedge\pi\right)\times P\left(O^{t}\mid S^{t}\wedge\pi\right)\right]\end{array}\right]\end{cases}\\ Fo:\\ \begin{cases} P\left(S^{0}\wedge O^{0}\mid\pi\right)\equiv \text{Matrix}\\ P\left(S^{t}\mid S^{t-1}\wedge\pi\right)\equiv \text{Matrix}\\ P\left(O^{t}\mid S^{t}\wedge\pi\right)\equiv \text{Matrix}\end{cases}\end{cases}\\ Id\end{cases}\\ Qu:\\ \max_{S^{1}\wedge\cdots\wedge S^{T-1}}\left[P\left(S^{1}\wedge\cdots\wedge S^{T-1}\mid S^{T}\wedge O^{0}\wedge\cdots\wedge O^{T}\wedge\pi\right)\right]\end{cases} Variables are treated as being discrete. The transition model P\left(S^{t}\mid S^{t-1}\wedge\pi\right) and the observation model P\left(O^{t}\mid S^{t}\wedge\pi\right) are both specified using probability matrices. The question most frequently asked of HMMs is: \max_{S^{1}\wedge\cdots\wedge S^{T-1}}\left[P\left(S^{1}\wedge\cdots\wedge S^{T-1}\mid S^{T}\wedge O^{0}\wedge\cdots\wedge O^{T}\wedge\pi\right)\right] What is the most probable series of states that leads to the present state, knowing the past observations? This particular question may be answered with a specific and very efficient algorithm called the Viterbi algorithm. The Baum–Welch algorithm has been developed for HMMs. ==Further reading==

References

No reference rows published for this article.

Cite this article

MLA

"Bayesian programming." encyclopegia.org, 2026, https://encyclopegia.org/wiki/bayesian-programming. Accessed 24 November 2026.

Chicago

"Bayesian programming." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/bayesian-programming.

APA

encyclopegia.org. (2026). Bayesian programming. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/bayesian-programming

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Banking Industry Architecture Network

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1374677658 · 0.5 · snapshot enwiki-001374677658

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.