1. Home
  2. Explore
  3. Statistics
  4. Bayesian Statistics Introduction

Study methods

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

Bayesian Statistics Introduction

Bayesian Statistics

This section introduces Bayesian statistics, contrasting it with the frequentist approach, and covers the core concepts of priors, posteriors, and conjugate priors through examples.


Frequentist vs. Bayesian Statistics

In frequentist statistics, the paradigm used throughout most of this course, the data is assumed to be generated randomly from a distribution indexed by an unknown but fixed parameter θ\thetaθ. The goal is to estimate or test hypotheses about this fixed parameter using tools from probability, such as assuming the data are i.i.d. or follow a specific parametric model (e.g., Gaussian, Bernoulli). The parameter is considered a constant, and uncertainty is expressed through confidence intervals or p-values.

In Bayesian statistics, the parameter is treated as a random variable. The data generation involves a two-layer process:

  1. A prior distribution π(θ)\pi(\theta)π(θ) captures the analyst's belief about the parameter before seeing any data.

  2. Conditional on θ\thetaθ, the data X1,…,XnX_1,\ldots,X_nX1​,…,Xn​ are drawn from a distribution pn(X1,…,Xn∣θ)p_n(X_1,\ldots,X_n \mid \theta)pn​(X1​,…,Xn​∣θ) — the same likelihood used in frequentist inference.

This framework allows one to incorporate prior knowledge into the analysis systematically. As more data is collected, the influence of the prior diminishes. The goal is to update the prior into a posterior distribution π(θ∣X1,…,Xn)\pi(\theta \mid X_1,\ldots,X_n)π(θ∣X1​,…,Xn​) using Bayes’ rule. This posterior summarizes all information about θ\thetaθ after observing the data.

Key takeaway: In Bayesian inference, parameters are random; in frequentist inference, they are fixed but unknown.


Example: Bernoulli Model with a Beta Prior

Consider estimating ppp, the proportion of women in a population. Data X1,…,XnX_1,\ldots,X_nX1​,…,Xn​ are i.i.d. Bernoulli(ppp) with p∈[0,1]p \in [0,1]p∈[0,1]. The analyst has a prior belief that ppp is close to 0.50.50.5 but not exactly. This belief can be encoded using a Beta distribution, which is a convenient family of distributions supported on [0,1][0,1][0,1].

Beta distribution: X∼Beta(a,b)X \sim \text{Beta}(a,b)X∼Beta(a,b) has density

f(x)∝xa−1(1−x)b−1,x∈[0,1],f(x) \propto x^{a-1} (1-x)^{b-1}, \quad x \in [0,1],f(x)∝xa−1(1−x)b−1,x∈[0,1],

where a>0a>0a>0 and b>0b>0b>0 are shape parameters. The normalizing constant involves the Beta function. When a=ba=ba=b, the distribution is symmetric about 0.50.50.5; larger aaa gives sharper concentration around the mean.

Prior specification

Let the prior for ppp be Beta(a,a)\text{Beta}(a,a)Beta(a,a) (symmetric around 0.50.50.5). The density is

π(p)∝pa−1(1−p)a−1.\pi(p) \propto p^{a-1} (1-p)^{a-1}.π(p)∝pa−1(1−p)a−1.

Likelihood

The joint density (likelihood) of the data given ppp is

pn(X1,…,Xn∣p)=p∑i=1nXi(1−p)n−∑i=1nXi.p_n(X_1,\ldots,X_n \mid p) = p^{\sum_{i=1}^n X_i} (1-p)^{n - \sum_{i=1}^n X_i}.pn​(X1​,…,Xn​∣p)=p∑i=1n​Xi​(1−p)n−∑i=1n​Xi​.

Posterior via Bayes’ rule

The posterior is proportional to likelihood times prior:

π(p∣X1,…,Xn)∝p∑Xi+a−1(1−p)n−∑Xi+a−1.\pi(p \mid X_1,\ldots,X_n) \propto p^{\sum X_i + a - 1} (1-p)^{n - \sum X_i + a - 1}.π(p∣X1​,…,Xn​)∝p∑Xi​+a−1(1−p)n−∑Xi​+a−1.

This is again a Beta distribution with parameters

a′=∑i=1nXi+a,b′=n−∑i=1nXi+a.a' = \sum_{i=1}^n X_i + a, \quad b' = n - \sum_{i=1}^n X_i + a.a′=∑i=1n​Xi​+a,b′=n−∑i=1n​Xi​+a.

Thus the Beta distribution is a conjugate prior for the Bernoulli likelihood: the posterior is in the same family as the prior. Conjugacy simplifies computation because updating only requires adjusting the parameters — essentially, the number of successes (∑Xi\sum X_i∑Xi​) and failures (n−∑Xin - \sum X_in−∑Xi​) are added to the prior parameters.

Key takeaway: For Bernoulli data, a Beta prior yields a Beta posterior. The posterior parameters are the prior parameters plus the observed counts.


Bayes’ Rule and the Posterior

Formally, for any model with parameter θ\thetaθ and data X=(X1,…,Xn)X = (X_1,\ldots,X_n)X=(X1​,…,Xn​), the posterior distribution is

π(θ∣X)=pn(X∣θ) π(θ)∫pn(X∣θ) π(θ) dθ,\pi(\theta \mid X) = \frac{p_n(X \mid \theta) \,\pi(\theta)}{\int p_n(X \mid \theta)\,\pi(\theta)\,d\theta},π(θ∣X)=∫pn​(X∣θ)π(θ)dθpn​(X∣θ)π(θ)​,

where:

  • pn(X∣θ)p_n(X \mid \theta)pn​(X∣θ) is the likelihood.

  • π(θ)\pi(\theta)π(θ) is the prior density.

  • The denominator is the marginal likelihood (or evidence), a normalizing constant that does not depend on θ\thetaθ.

In practice, one often works with the unnormalized posterior:

π(θ∣X)∝pn(X∣θ) π(θ).\pi(\theta \mid X) \propto p_n(X \mid \theta) \,\pi(\theta).π(θ∣X)∝pn​(X∣θ)π(θ).

This product of likelihood and prior is the key object. The maximum of this function is called the maximum a posteriori (MAP) estimate. However, the full posterior distribution contains more information, such as spread (uncertainty) and shape.


Non-informative and Improper Priors

When no prior knowledge is available, one may use a non-informative prior that does not favor any value of θ\thetaθ over others. For a parameter on a bounded space (e.g., [0,1][0,1][0,1] for ppp), a uniform prior π(p)=1\pi(p) = 1π(p)=1 (or constant) is natural.

However, for an unbounded parameter space (e.g., the real line), a uniform density over R\mathbb{R}R is not a valid probability density because it does not integrate to a finite number. Such a prior is called an improper prior. It can still be used in Bayes’ rule if the resulting posterior is proper (integrates to one). This is common with location parameters.

Example: Bernoulli with uniform prior

If π(p)=1\pi(p) = 1π(p)=1 on [0,1][0,1][0,1], then the posterior becomes

π(p∣X)∝p∑Xi(1−p)n−∑Xi,\pi(p \mid X) \propto p^{\sum X_i} (1-p)^{n - \sum X_i},π(p∣X)∝p∑Xi​(1−p)n−∑Xi​,

which is Beta(∑Xi+1,n−∑Xi+1)\text{Beta}(\sum X_i + 1, n - \sum X_i + 1)Beta(∑Xi​+1,n−∑Xi​+1). This “adds one” to each count, automatically avoiding degenerate estimates when all observations are zero or one. The posterior mean is (∑Xi+1)/(n+2)(\sum X_i + 1)/(n+2)(∑Xi​+1)/(n+2), slightly shrunk toward 1/21/21/2 compared to the sample mean Xˉ\bar{X}Xˉ.

Example: Gaussian with unknown mean

Let X1,…,Xn∣θ∼N(θ,1)X_1,\ldots,X_n \mid \theta \sim \mathcal{N}(\theta,1)X1​,…,Xn​∣θ∼N(θ,1) (known variance). Using an improper uniform prior π(θ)∝1\pi(\theta) \propto 1π(θ)∝1 on R\mathbb{R}R, the posterior becomes

π(θ∣X)∝exp⁡{−12∑i=1n(Xi−θ)2}.\pi(\theta \mid X) \propto \exp\left\{ -\frac{1}{2} \sum_{i=1}^n (X_i - \theta)^2 \right\}.π(θ∣X)∝exp{−21​∑i=1n​(Xi​−θ)2}.

Completing the square yields:

π(θ∣X)∝exp⁡{−n2(θ−Xˉ)2},\pi(\theta \mid X) \propto \exp\left\{ -\frac{n}{2} (\theta - \bar{X})^2 \right\},π(θ∣X)∝exp{−2n​(θ−Xˉ)2},

so the posterior is N(Xˉ,1/n)\mathcal{N}(\bar{X}, 1/n)N(Xˉ,1/n). The posterior mean is the sample mean, and the variance decreases as 1/n1/n1/n.

If a conjugate Gaussian prior θ∼N(μ,1)\theta \sim \mathcal{N}(\mu, 1)θ∼N(μ,1) is used, the posterior is also Gaussian with mean that is a weighted average of the prior mean μ\muμ and the sample mean Xˉ\bar{X}Xˉ, essentially treating the prior as one extra observation.


Jeffrey’s Priors

Jeffrey’s priors provide a systematic way to define non-informative priors that are invariant under reparameterization. They are defined as

π(θ)∝det⁡I(θ),\pi(\theta) \propto \sqrt{\det I(\theta)},π(θ)∝detI(θ)​,

where I(θ)I(\theta)I(θ) is the Fisher information matrix.

This prior places more weight on parameter values that carry more information (higher Fisher information). For example:

  • Bernoulli: I(p)=1p(1−p)I(p) = \frac{1}{p(1-p)}I(p)=p(1−p)1​, so π(p)∝1p(1−p)\pi(p) \propto \frac{1}{\sqrt{p(1-p)}}π(p)∝p(1−p)​1​, which puts more mass near 000 and 111.

  • Gaussian mean (variance known): I(θ)=1I(\theta) = 1I(θ)=1, so π(θ)∝1\pi(\theta) \propto 1π(θ)∝1, matching the improper uniform prior.

A key property is invariance under one-to-one reparameterization: if ϕ=g(θ)\phi = g(\theta)ϕ=g(θ) is a smooth reparameterization, then the Jeffrey’s prior for ϕ\phiϕ is also proportional to det⁡I(ϕ)\sqrt{\det I(\phi)}detI(ϕ)​, ensuring consistent inference regardless of how the model is parameterized.


Next Steps: Bayesian Estimation and Confidence Regions

In the full lecture, the discussion continues with using the posterior for point estimation (e.g., posterior mean) and Bayesian credible regions (the Bayesian analog of confidence intervals). The central idea is to integrate against the posterior to produce summaries. These methods are explored further in subsequent recordings.

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent