1. Home
  2. Explore
  3. Mathematics
  4. Rise of Bayesian Statistics

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Rise of Bayesian Statistics

Bayesian Statistics and Probabilistic Programming

Introduction

The number of research publications mentioning "Bayesian" has been increasing every year since 2000, with a noticeable change in trajectory around 2017–2018. Although the underlying concepts date back to the 1700s, modern computational power has driven the recent surge. Bayesian inference uses probability theory to update uncertain beliefs in light of data, making it essential across the social, biological, and physical sciences.

"There are some ideas we know are true, and others we know are false. However, for the majority of ideas, we do not know if they are true or false; for these we say, we are 'uncertain'. For these uncertain entities, the correct way to quantify our ignorance is to use the language of probability. Bayesian inference uses probability theory to allow us to update our uncertain beliefs in light of data." — Ben Lambert


Probability Interpretations

Historically, probability has been interpreted either objectively or subjectively.

  • Objectivist: Probability measures the real physical tendency of an event to occur. This view dominated mathematics for most of modern history.

  • Subjectivist: Probability measures how strongly one believes an event will occur. This perspective has gained popularity in recent years.

Bayesian Statistics is perhaps the best-known application of subjective probability. Despite being named after Thomas Bayes, the framework was actually developed by Pierre-Simon Laplace in the late 18th and early 19th centuries. What distinguishes Bayesian statistics is its interpretation of probability as a degree of belief.


Bayes' Theorem

Thomas Bayes (1700s) formulated what is now called Bayes' Theorem, which describes the probability of an event based on prior knowledge of conditions related to it. The theorem is written as:

P(A∣B)=P(B∣A)⋅P(A)P(B)P(A|B) = \frac{P(B|A) \cdot P(A)}{P(B)}P(A∣B)=P(B)P(B∣A)⋅P(A)​

where AAA and BBB are events, and P(B)≠0P(B) \neq 0P(B)=0. The vertical bar (∣|∣) denotes conditional probability, so P(A∣B)P(A|B)P(A∣B) is read as "the probability of AAA given BBB".

Although this equation is simple, it has been interpreted and applied in many ways. In Bayesian Statistics, it is used for Bayesian Inference.

Terminology in Bayes' Theorem

  • Posterior Probability: P(A∣B)P(A|B)P(A∣B) — the updated probability after considering evidence.

  • Likelihood: P(B∣A)P(B|A)P(B∣A) — the probability of the evidence given the hypothesis.

  • Prior Probability: P(A)P(A)P(A) — the initial belief before evidence.

  • Marginal Probability: P(B)P(B)P(B) — the total probability of the evidence, often difficult or impossible to calculate. It serves to normalize the distribution and is frequently omitted, yielding:

P(A∣B)∝P(B∣A)⋅P(A)P(A|B) \propto P(B|A) \cdot P(A)P(A∣B)∝P(B∣A)⋅P(A)

Bayesian Inference

Inference in statistics refers to drawing conclusions about a population from a sample. Bayesian inference uses Bayes' Theorem to update a prior belief as more information becomes available.

In Bayesian inference, the events are replaced:

  • Event A → the parameter(s) of interest, often denoted by θ\thetaθ.

  • Event B → the observation(s) or data, often denoted by XXX.

Thus the equation becomes:

P(θ∣X)∝P(θ)⋅P(X∣θ)P(\theta|X) \propto P(\theta) \cdot P(X|\theta)P(θ∣X)∝P(θ)⋅P(X∣θ)

In English: you start with a prior belief P(θ)P(\theta)P(θ) about the parameter before making observations. Then you collect data XXX. Using the likelihood P(X∣θ)P(X|\theta)P(X∣θ), you update your belief to the posterior P(θ∣X)P(\theta|X)P(θ∣X).

Bayesian inference iteratively updates beliefs: new data leads to a new posterior, which can serve as a prior for future updates.

The reason Bayesian methods were not widely used until recently is that solving Bayes' Theorem by hand is often mathematically intractable. With modern computers and programming languages, Bayesian inference has become practical.


Probabilistic Programming

The use of modern computers and languages for Bayesian statistics is called Probabilistic Programming. Probabilistic programming languages have existed for decades, but a key milestone was the release of Stan in 2012, an open-source domain-specific language written in C++ and developed by a team with ties to Columbia University. Since Stan, many other libraries have emerged. One notable package in Julia is Turing.jl, created by Hong Ge at the University of Cambridge and originally released in 2018. Unlike Stan, Turing is a Julia package that integrates naturally, requiring no additional language.

Probabilistic Programming Workflow

When using Turing.jl, the user provides:

  1. Observe an event or events (data).

  2. Define a model using the @model macro.

  3. Select an inference algorithm (sampler).

The automated step uses the inference algorithm to build a Chain (or chains), which is an approximation of the posterior probability.


Workflow with Turing.jl (Globe Tossing Example)

The example from the source: 9 globe tosses resulted in 6 "water" and 3 "land". The goal is to infer the proportion of water on the globe.

Model Definition

Using the @model macro, the model implements Bayes' Theorem as Posterior = Prior × Likelihood:

@model function globe_tossing(water, tosses)
    percent_water ~ Beta(1, 1)   # Prior: uniform Beta distribution
    water ~ Binomial(tosses, percent_water)  # Likelihood
end
  • Prior belief: The parameter percent_water follows a uniform Beta distribution (Beta(1,1)\text{Beta}(1,1)Beta(1,1)), meaning any value between 0 and 1 is equally likely.

  • Likelihood: Given the parameter, the observed data (number of water outcomes) follows a Binomial distribution with tosses trials and success probability percent_water.

Sampling

Because the posterior is often not directly calculable, a random sampling process is used to approximate the posterior distribution. In Turing, this is done with the sample() function:

chain = sample(model, sampler, num_samples)

The function takes three arguments:

  • A model

  • A sampler (inference algorithm)

  • The number of samples

The result is a Chain, which represents the approximate posterior.


Markov Chain Monte Carlo (MCMC)

Markov Chain Monte Carlo (MCMC) is a class of algorithms for intelligently and efficiently sampling from a probability distribution. As models grow complex, naive random sampling becomes computationally expensive, so MCMC methods are essential.

MCMC Algorithms in Turing.jl

Turing offers several MCMC samplers:

  • Gibbs

  • Hamiltonian Monte Carlo (HMC)

  • HMC with Dual Averaging

  • Importance Sampling

  • Metropolis-Hastings

  • No-U-Turn Sampler (NUTS)

  • Particle Gibbs

  • Sequential Monte Carlo

The No-U-Turn Sampler (NUTS) is a state-of-the-art algorithm used in the globe tossing example. It intelligently selects random values for the parameter in proportion to the posterior probability, discarding samples that do not fit, and continues until the specified number of samples is obtained.

How MCMC Works

  1. The sampler selects random parameter values, guided by the prior and likelihood.

  2. It retains or discards samples based on a selection criterion that fits the proportional shape of the posterior.

  3. The process repeats for the specified number of samples.

  4. The result is a chain — an approximation of the posterior distribution.


The Posterior Distribution

The posterior is the updated belief after observing data. In the globe tossing example, the prior was uniform (any proportion equally likely). After 6 water outcomes out of 9 tosses, the posterior distribution is concentrated between 60% and 80% — reflecting the updated belief that the true proportion of water is most likely in that range.

The posterior is not a fixed answer; it is a distribution that quantifies remaining uncertainty. Bayesian inference is iterative: new data can further update the belief, with the current posterior becoming the new prior.


Why Bayesian Statistics Matters

Ben Lambert's quote captures the essence: science deals with uncertainty, and Bayesian methods provide a principled way to quantify and update uncertainty as evidence accumulates. This resonates deeply in scientific research, where exploring the unknown is central.

"Bayesian inference uses probability theory to allow us to update our uncertain beliefs in light of data."

Bayesian statistics and probabilistic programming equip researchers with practical tools to navigate a world full of uncertainty, making them increasingly vital across disciplines.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent