Why Derive the Posterior Update?
With normal outcomes, a normal prior gives a normal posterior for a treatment’s unknown response mean when the observation variance is known. The update is useful in Thompson sampling because it turns each treatment’s accumulated outcomes into a distribution from which its mean can be drawn. The draw, rather than just the current posterior mean, allows uncertainty to affect allocation.
The result depends on a specific model: outcomes within an arm are independent and normally distributed around that arm’s mean, the observation variance is known, and the prior for the mean is normal. These assumptions distinguish the calculation from an update that estimates the outcome variance as well. Here, the posterior variance describes uncertainty about the unknown mean; it is not the variance of an individual response.
Deriving the Normal-Normal Posterior
The likelihood, as a function of \(\mu\), is proportional to \(\exp[-\sum_{i=1}^{n}(x_i-\mu)^2/(2\sigma^2)]\). The prior density is proportional to \(\exp[-(\mu-\mu_0)^2/(2\tau_0^2)]\). Multiplying them gives the posterior density up to a factor that does not depend on \(\mu\). To identify its distribution, collect the terms involving \(\mu\) in the exponent.
Since \(\sum_{i=1}^{n}(x_i-\mu)^2=\sum_{i=1}^{n}(x_i-\bar{x})^2+n(\bar{x}-\mu)^2\), the first term on the right does not depend on \(\mu\). The remaining quadratic terms in the log posterior are
Let \(V_n\) be the reciprocal of the coefficient of \(\mu^2\) inside the brackets. Completing the square identifies the posterior mean as \(V_n\) times the coefficient multiplying \(\mu\) in the linear term. Therefore,
This derivation also gives a useful interpretation: posterior precision is prior precision plus data precision. The posterior mean is a precision-weighted average of the prior mean and the sample mean:
The weight on \(\bar{x}\) grows with the number of observations and shrinks as the known observation variance increases. The prior contribution does not disappear by assertion; it becomes relatively smaller as the data precision \(n/\sigma^2\) increases. When \(n=0\), the formulas return the prior mean and variance.
Worked Example: Updating One Treatment Mean
Suppose a hypothetical treatment has a normal prior \(\mu\sim N(10,4)\), and each response has known variance \(\sigma^2=9\). Four observed responses are 12, 9, 11, and 10, so \(n=4\) and \(\bar{x}=10.5\). Assume these observations are independent conditional on \(\mu\), and that the outcome model and prior just stated are appropriate.
The posterior variance is
The posterior mean is
Thus \(\mu\mid x_1,\ldots,x_4\sim N(10.32,1.44)\), with posterior standard deviation \(\sqrt{1.44}=1.20\) response units. The data move the posterior mean above the prior mean of 10 because the sample mean is 10.5. The variance 1.44 is uncertainty about the treatment’s mean, not the response variance of 9.
Using Posterior Draws for Allocation
For each treatment arm \(j\), let its mean response be \(\mu_j\), its known within-arm variance be \(\sigma_j^2\), and its prior be \(\mu_j\sim N(\mu_{0j},\tau_{0j}^2)\). Given \(n_j\) responses with sample mean \(\bar{x}_j\), apply the preceding formulas using that arm’s quantities. If the arm priors and response models are independent across arms, the resulting posterior distributions are independent conditional on the observed trial data.
When larger responses are preferred, a Thompson allocation step draws one value from each treatment’s posterior and assigns the next participant to the arm with the largest draw. The draw is a temporary representation of uncertainty about that arm’s mean, not a new observed response. With two arms, the probability that an assignment goes to arm A is the posterior probability \(P(\mu_A>\mu_B\mid\text{data})\), provided ties have probability zero. In practice, repeated independent posterior draws can estimate this probability by the fraction of draws for which arm A has the largest value.
Worked Example: Drawing and Comparing Two Treatment Means
Consider a hypothetical trial with two independent arms. For each arm, use prior \(N(0,16)\) and known response variance 25. Arm A has \(n_A=9\) responses with \(\bar{x}_A=4\); arm B has \(n_B=4\) responses with \(\bar{x}_B=3\). Assume independent normal outcomes within each arm and independent priors across arms. Larger outcomes are preferred.
For arm A, the posterior variance and mean are
For arm B,
The posterior standard deviations are approximately 1.538 for A and 2.120 for B. For one illustrative allocation step, suppose independent standard normal draws happen to be \(Z_A=0.50\) and \(Z_B=-0.40\). Transforming them gives
This draw selects arm A because 4.769 exceeds 1.309. It does not mean that arm A is certain to be better. Other posterior draws can select B, particularly because B’s posterior uncertainty is greater. A single draw illustrates the assignment mechanism; estimating the probability of assignment to A by simulation requires many draws.
Sequential Updating and a Useful Check
The same formula can be applied after each response or to all responses accumulated so far. For a fixed known \(\sigma^2\), updating sequentially produces the same posterior as using the full sample: each new independent observation adds \(1/\sigma^2\) to precision and \(x_i/\sigma^2\) to the precision-weighted mean numerator. This provides a practical check on an implementation.
Worked Example: Checking an Update After Each Response
Suppose a hypothetical arm has prior \(\mu\sim N(5,4)\), known response variance \(\sigma^2=16\), and three responses 7, 1, and 9. Assume independent normal responses with the stated variance. After the first two responses, their mean is 4. The posterior is
After the third response, the sample mean is \(17/3=5.667\). Updating from the original prior using all three observations gives
Alternatively, start from the two-response posterior. The third observation adds precision \(1/16\) and a weighted response \(9/16\):
Both calculations agree. A discrepancy in this check often signals that an observation was omitted or counted twice, or that a variance was used where a standard deviation was required.
Assumptions, Diagnostics, and Alternatives
The update is exact under the stated model, but that does not make the model automatically suitable for a clinical outcome. Check that the response scale is meaningfully represented by a normal distribution, that observations are conditionally independent within each arm, and that the known \(\sigma^2\) is defensible. A normal likelihood can be a poor description for highly skewed, bounded, binary, or count outcomes. The known-variance condition is substantive: replacing \(\sigma^2\) by a sample variance does not give this same normal posterior in general.
For implementation, check that posterior variances are positive, that \(V_n<\tau_0^2\) whenever \(n>0\), and that the posterior mean lies between \(\mu_0\) and \(\bar{x}\). The last check follows because both receive positive precision weights. For a simulated allocation, verify that each draw uses the current posterior parameters and that the correct direction of preference is used. If smaller outcomes are better, select the smallest draw, or define a utility with larger values representing better outcomes.
The posterior mean alone gives a plug-in greedy rule: choose the arm with the largest \(m_j\). That rule ignores uncertainty in the means and is not posterior sampling. Thompson sampling instead draws from the posterior, allowing a less certain arm to be selected on some assignments. A diffuse or flat-prior analysis is another possible reference, but it does not encode the same prior information; a normal prior with very large variance can approximate a flat prior over a relevant range, while still requiring care about whether the approximation is appropriate.
This conjugate calculation is simple and transparent, but its convenience is also a limitation. It relies on a known variance, a normal sampling model, and (for separate arm-by-arm updates) independent arm priors. It does not account for shared parameters or dependence between treatment means. If those assumptions are not credible, the resulting posterior draws may misrepresent uncertainty and therefore affect allocation in the wrong direction.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- Under what assumptions does the normal-normal posterior formula apply, and which variance must be known?
- A prior has variance 9, the known response variance is 4, and \(n=2\). Calculate the posterior variance.
- Why is selecting the arm with the largest posterior mean not the same rule as Thompson sampling?
- For a treatment with posterior \(N(6,1)\), what value results from a standard normal draw \(Z=-1.2\)?
Solutions. (1) The observations must be conditionally independent normal outcomes with a common treatment mean and known response variance; the prior for that mean must be normal. The known variance is the outcome-level \(\sigma^2\), not the posterior variance of the mean. (2) \(V_n=(1/9+2/4)^{-1}=(11/18)^{-1}=18/11=1.636\). (3) The largest-posterior-mean rule uses only point estimates, whereas Thompson sampling draws a mean from each posterior and selects the largest draw, so uncertainty can change the selected arm. (4) The posterior standard deviation is 1, so the draw is \(6+1(-1.2)=4.8\).