Bayesian Posterior for a Biased Die

Statistics · Medium · Free problem

A biased die has an unknown probability $\theta = P(\text{roll} = 6)$. You place a $\text{Beta}(2, 8)$ prior on $\theta$ -- reflecting a prior belief that sixes are rare (prior mean $= 0.2$).

You roll the die $n = 20$ times and observe $k = 6$ sixes.

  1. Derive the posterior distribution of $\theta$ given the data.
  2. Compute $P(\theta > 0.30 \mid \text{data})$ and express it in terms of the regularized incomplete beta function $I_x(a, b)$. No numeric integration required.

Hints

  1. Beta is the conjugate prior for the Binomial likelihood -- the posterior is also Beta. Just update the shape parameters.
  2. The update rule: if the prior is $\text{Beta}(\alpha, \beta)$ and you observe $k$ successes in $n$ trials, the posterior is $\text{Beta}(\alpha + k, \beta + n - k)$.
  3. To express a tail probability for a Beta random variable, recall that $P(\theta \leq x) = I_x(a, b)$ by definition of the regularized incomplete beta function.

Worked Solution

How to Think About It: The Beta-Binomial model is the canonical conjugate pair: a Beta prior on a success probability combined with Binomial observations always yields a Beta posterior. The update rule is simple -- just add the observed successes and failures to the prior shape parameters. The prior $\text{Beta}(2, 8)$ encodes the equivalent of having seen 1 success and 7 failures before (the extra 1 in each comes from the pseudo-count interpretation). After 6 actual sixes in 20 rolls, you just update those counts.

Quick Estimate: Prior mean: $\hat{\theta}_{\text{prior}} = 2/(2+8) = 0.20$. Posterior mean will be a weighted average toward the data: observed rate is $6/20 = 0.30$. After the update, posterior mean $= (2+6)/(2+8+20) = 8/30 \approx 0.267$. So the data pulled your estimate from 0.20 toward 0.30, landing at about 0.27. The question asks whether there is meaningful probability mass above 0.30 -- given the posterior mean is 0.267 and the distribution has some spread, there is a non-trivial chunk above 0.30.

Formal Solution:

Part 1: Posterior Distribution

The likelihood for $k$ sixes in $n$ rolls is: $$L(\theta \mid k, n) \propto \theta^k (1-\theta)^{n-k}$$

With a $\text{Beta}(\alpha, \beta) = \text{Beta}(2, 8)$ prior: $$\pi(\theta) \propto \theta^{\alpha - 1}(1-\theta)^{\beta - 1}$$

By Bayes' theorem: $$\pi(\theta \mid k, n) \propto \theta^{\alpha + k - 1}(1-\theta)^{\beta + n - k - 1}$$

This is the kernel of a $\text{Beta}(\alpha + k,\; \beta + n - k)$ distribution. Substituting $\alpha = 2$, $\beta = 8$, $n = 20$, $k = 6$:

$$\boxed{\theta \mid \text{data} \sim \text{Beta}(8, 22)}$$

Posterior mean: $8/30 \approx 0.267$. Posterior variance: $8 \cdot 22 / (30^2 \cdot 31) \approx 0.0063$.

Part 2: $P(\theta > 0.30 \mid \text{data})$

The CDF of a $\text{Beta}(a, b)$ random variable evaluated at $x$ is the regularized incomplete beta function $I_x(a, b)$. So:

$$P(\theta \leq 0.30 \mid \text{data}) = I_{0.30}(8, 22)$$

Therefore: $$\boxed{P(\theta > 0.30 \mid \text{data}) = 1 - I_{0.30}(8, 22)}$$

Answer: Posterior is $\text{Beta}(8, 22)$; the probability that $\theta > 0.30$ is $1 - I_{0.30}(8, 22)$.

Intuition

The Beta-Binomial conjugate pair is worth internalizing deeply -- it is the foundation for Bayesian A/B testing, market making with unknown adverse selection probability, and any situation where you are learning a success rate from data. The key structural point is that the prior and posterior have the same functional form, making sequential updating trivial: each new batch of data just adds to the running tallies of successes and failures.

The incomplete beta function appears naturally here because the Beta distribution's CDF does not have a simpler closed form. In practice, you would compute this numerically (scipy.stats.beta.sf(0.30, 8, 22) gives about 0.26), but the exam skill is recognizing the form and not attempting to integrate by hand. The deeper lesson: when an interviewer says 'express in terms of the incomplete beta function,' they are testing whether you know the CDF machinery, not asking you to compute a number.

Open the full interactive solver →