Tutorials › Response-Adaptive Randomization › Thompson Sampling With Unequal Arm Priors

Thompson Sampling for Trials · Tutorial 255 of 501

Thompson Sampling With Unequal Arm Priors

Learn to compute two-arm Thompson sampling allocations under unequal Beta priors and interpret how prior information changes the probability each treatment is assigned.

Advanced 12 min read

What You'll Learn

  • Express each arm’s posterior allocation probability as a probability that one posterior draw exceeds the other.
  • Calculate allocation probabilities for unequal Beta priors using posterior distributions and integrals.
  • Trace how prior means and prior strength combine with binary outcomes to change allocation.
  • Compare allocation probabilities under alternative priors while holding observed data fixed.
  • Diagnose when an allocation probability may be sensitive to prior assumptions or unreliable outcome data.

Why Unequal Priors Change Allocation

In Thompson sampling, a treatment is selected by drawing a plausible response rate from each treatment’s current posterior distribution and assigning the next participant to the treatment with the largest draw. When the arms have unequal priors, their posterior distributions can differ before any trial outcomes are observed. The allocation probabilities can therefore differ even at the start of the trial.

This is more than a change in the estimated response rates. Thompson sampling uses the full posterior distributions, including their uncertainty. A prior with a higher mean can make an arm more likely to receive the next assignment, while a more concentrated prior can make its response-rate draws less variable. The allocation probability depends on how the two distributions compare, not just on which posterior mean is larger.

Assume a two-arm trial with independent binary outcomes, where a response is the favorable outcome and a higher response rate is better. For arm \(k\), let \(\theta_k\) be its response probability. The model is \(X_{ki}\mid\theta_k\sim\operatorname{Bernoulli}(\theta_k)\), with a Beta prior for each arm. Outcomes are assumed to be observed and recorded according to this model, and the arm-specific priors are assumed independent. These assumptions make the posterior distributions independent Beta distributions.

Definition: If arm \(k\) has prior \(\theta_k\sim\operatorname{Beta}(a_k,b_k)\), and its observed data include \(s_k\) responses and \(f_k\) nonresponses, then its posterior is \(\theta_k\mid\text{data}\sim\operatorname{Beta}(a_k+s_k,b_k+f_k)\). Under two-arm Thompson sampling, the probability of assigning the next participant to arm 1 is \(P(\theta_1>\theta_2\mid\text{data})\); the probability of assigning to arm 2 is \(P(\theta_2>\theta_1\mid\text{data})\). With continuous Beta posteriors, ties have probability zero.

The Beta prior mean is \(a_k/(a_k+b_k)\), and \(a_k+b_k\) is often used as a measure of prior strength or effective sample size. It is a convenient way to describe concentration, not necessarily a literal number of observed patients. After data are observed, the posterior mean is \((a_k+s_k)/(a_k+b_k+s_k+f_k)\). These means summarize each posterior, but the allocation probability compares the distributions themselves.

Calculating the Probability of a Posterior Win

Write the two posterior distributions as \(\theta_1\mid\text{data}\sim\operatorname{Beta}(A_1,B_1)\) and \(\theta_2\mid\text{data}\sim\operatorname{Beta}(A_2,B_2)\), where \(A_k=a_k+s_k\) and \(B_k=b_k+f_k\). If \(F_2\) is the cumulative distribution function of the second posterior and \(f_1\) is the density of the first, independence gives

$$ P(\theta_1>\theta_2\mid\text{data}) =\int_0^1 f_1(x)F_2(x)\,dx. $$

To see why, condition on a possible draw \(\theta_1=x\). Given that draw, arm 1 wins whenever the independent draw from arm 2 is below \(x\), an event with probability \(F_2(x)\). Averaging that conditional probability over draws from arm 1 gives the integral. This identity is also useful for numerical integration; simulation can approximate the same probability by repeatedly drawing from both posteriors and recording which draw is larger.

For a simple closed-form calculation, if \(Y\sim\operatorname{Beta}(1,d)\), then \(F_Y(x)=1-(1-x)^d\). If \(X\sim\operatorname{Beta}(a,1)\), its density is \(ax^{a-1}\), so

$$ P(X>Y) =1-E[(1-X)^d] =1-\frac{B(a,d+1)}{B(a,1)}, $$

where \(B(u,v)=\int_0^1 x^{u-1}(1-x)^{v-1}\,dx\) is the Beta function. This follows by substituting the density of \(X\) into the expectation. The same integral definition applies when the posterior shapes do not give such a short expression.

Worked Example: Unequal Priors Before Any Outcomes

Suppose arm 1 has prior \(\operatorname{Beta}(2,2)\) and arm 2 has prior \(\operatorname{Beta}(1,3)\). There are no observed trial outcomes yet. Both priors are proper, independent distributions on response rates, and higher response is the favorable direction.

The prior means are \(2/(2+2)=0.500\) for arm 1 and \(1/(1+3)=0.250\) for arm 2. To calculate the initial probability of assigning to arm 1, let \(X\sim\operatorname{Beta}(2,2)\) and \(Y\sim\operatorname{Beta}(1,3)\). The second distribution has \(F_Y(x)=1-(1-x)^3\), so

$$ P(X>Y) =1-E[(1-X)^3] =1-\frac{B(2,5)}{B(2,2)} =1-\frac{1/30}{1/6} =0.800. $$

Thus arm 1 receives the next assignment with probability 0.800 and arm 2 with probability \(1-0.800=0.200\). This is not a deterministic choice: arm 2 still has a positive chance of receiving the participant. The unequal priors alone create this allocation imbalance; no observed response data are needed.

Updating Unequal Priors With Trial Outcomes

To apply the allocation rule after outcomes accrue, first update each arm’s prior using its own response and nonresponse counts. Then calculate the probability that a draw from one posterior exceeds a draw from the other. The order matters: comparing prior means to choose an arm would omit both the observed evidence and the posterior uncertainty used by Thompson sampling.

Worked Example: Updating Each Arm Separately

Suppose arm 1 begins with prior \(\operatorname{Beta}(2,1)\) and arm 2 with prior \(\operatorname{Beta}(1,1)\). The observed data are one response and no nonresponse on arm 1, and no response and one nonresponse on arm 2. Assume the outcomes are binary, the recorded counts are correct, and the independent Beta-Bernoulli model is appropriate.

The posterior distributions are

$$ \theta_1\mid\text{data}\sim\operatorname{Beta}(2+1,1+0)=\operatorname{Beta}(3,1), \qquad \theta_2\mid\text{data}\sim\operatorname{Beta}(1+0,1+1)=\operatorname{Beta}(1,2). $$

Let \(X\) and \(Y\) be independent draws from these posteriors. Since \(Y\sim\operatorname{Beta}(1,2)\), \(F_Y(x)=1-(1-x)^2\), and \(X\sim\operatorname{Beta}(3,1)\) has density \(3x^2\). Therefore,

$$ \begin{aligned} P(X>Y) &=1-E[(1-X)^2]\\ &=1-3\int_0^1 x^2(1-x)^2\,dx\\ &=1-3B(3,3)\\ &=1-3\left(\frac{2!2!}{5!}\right) =1-0.100 =0.900. \end{aligned} $$

Thompson sampling therefore assigns the next participant to arm 1 with probability 0.900 and to arm 2 with probability 0.100. The posterior means are \(3/4=0.750\) and \(1/3=0.333\), respectively. Those means agree with the direction of the allocation preference, but the calculated allocation probability comes from comparing posterior draws, not merely from comparing the means.

A useful way to understand the role of unequal priors is to hold the observed data fixed and change the prior specification. If this changes the posterior distributions, it can change the probability of a posterior win and thus the randomization probability. The next example makes that sensitivity explicit.

Worked Example: Same Outcomes, Different Prior Assumptions

Suppose arm 1 has one response and arm 2 has one nonresponse. First use priors \(\operatorname{Beta}(2,1)\) for arm 1 and \(\operatorname{Beta}(1,2)\) for arm 2. Under the Beta-Bernoulli model, the posteriors are \(\operatorname{Beta}(3,1)\) and \(\operatorname{Beta}(1,3)\). The independent draws \(X\) and \(Y\) then satisfy

$$ P(X>Y) =1-E[(1-X)^3] =1-\frac{B(3,4)}{B(3,1)} =1-\frac{1/60}{1/3} =0.950. $$

Now keep the outcomes unchanged but use \(\operatorname{Beta}(1,1)\) priors for both arms. The posteriors become \(\operatorname{Beta}(2,1)\) and \(\operatorname{Beta}(1,2)\). For these posteriors,

$$ P(X>Y) =1-E[(1-X)^2] =1-2B(2,3) =1-2\left(\frac{1!2!}{4!}\right) =\frac{5}{6} \approx 0.833. $$

The arm 1 allocation probability is 0.950 under the first prior specification and 0.833 under the equal priors, despite identical observed outcomes. This comparison does not establish which prior is preferable. It shows why the clinical justification for prior means and strength matters: prior assumptions can influence assignments, especially when trial data are still sparse.

Interpreting, Checking, and Comparing the Allocation

The probability \(P(\theta_1>\theta_2\mid\text{data})\) is a posterior probability that arm 1 has the higher response rate, conditional on the model, priors, and observed data. In two-arm Thompson sampling, it is also the probability of assigning the next participant to arm 1, because the algorithm selects the arm with the larger independent posterior draw. It is not the probability that the next participant will respond if assigned to arm 1.

Before using a calculated allocation probability, check that the model and computation match the trial:

  • Confirm that the outcome is coded so the favorable direction is correct. If a lower rate is preferable, the comparison must reflect that direction.
  • Check the response and nonresponse counts against the trial record. A miscoded or missing outcome can change the posterior parameters.
  • Check that each prior is proper and that its mean and strength match the intended clinical information. A highly concentrated prior can exert substantial influence before much data accrue.
  • Check that the arm posteriors are independent as assumed here. If the model links treatment effects, multiplying independent arm distributions is not justified.
  • Validate numerical integration or simulation, especially when the calculated probability is near zero or one. A Monte Carlo estimate should be accompanied by enough draws to make its simulation error small relative to the precision reported.

The main alternatives answer different questions. Equal-prior Thompson sampling avoids prior differences between arms but does not remove the need to choose a prior distribution. A fixed allocation rule does not change assignment probabilities in response to accumulating outcomes. A rule that always selects the arm with the larger posterior mean uses a point summary and does not randomize according to posterior uncertainty. These alternatives may be appropriate for different trial aims, but they are not the unequal-prior Thompson sampling calculation shown here.

Unequal priors also have limitations. They can be clinically justified, but the resulting allocation may be sensitive to assumptions that are hard to elicit. A high probability of assigning to one arm does not by itself show that the trial will answer its scientific or safety questions well. Operational safeguards, the handling of missing outcomes, and the design’s inferential goals require separate consideration. If outcomes are not binary or treatment posteriors are dependent, the Beta-Bernoulli calculation above does not apply without a suitable model and a corresponding posterior comparison.

Common mistake: “Arm 1 has the higher posterior mean, so its Thompson sampling allocation probability equals its mean.” The correction is to compare independent posterior draws: calculate \(P(\theta_1>\theta_2\mid\text{data})\). A response-rate mean is a summary of one arm; it is not the probability that this arm’s draw exceeds the other arm’s draw.

Check Your Understanding

Use the independent Beta-Bernoulli model and assume that higher response rates are better.

  1. With no data, arm 1 has prior \(\operatorname{Beta}(1,1)\) and arm 2 has prior \(\operatorname{Beta}(1,2)\). What is the probability that Thompson sampling assigns to arm 1?
  2. Arm 1 has prior \(\operatorname{Beta}(1,1)\) and observes two responses. Arm 2 has prior \(\operatorname{Beta}(1,1)\) and observes one nonresponse. State both posterior distributions.
  3. Why does a more concentrated prior affect allocation even if its mean is unchanged?
  4. Does a 0.80 allocation probability for arm 1 mean that a participant assigned to arm 1 has an 0.80 probability of responding? Explain.

Solutions. (1) Let \(X\sim\operatorname{Beta}(1,1)\) and \(Y\sim\operatorname{Beta}(1,2)\). Then \(F_Y(x)=1-(1-x)^2\), and \(X\) is uniform, so \(P(X>Y)=1-\int_0^1(1-x)^2\,dx=1-1/3=2/3\approx0.667\). (2) The posteriors are \(\operatorname{Beta}(1+2,1+0)=\operatorname{Beta}(3,1)\) and \(\operatorname{Beta}(1+0,1+1)=\operatorname{Beta}(1,2)\). (3) Concentration changes posterior uncertainty and therefore changes how often draws from that arm exceed draws from the other, even when the means match. (4) No. The 0.80 is the probability of assigning the next participant to arm 1 under Thompson sampling, equivalently the posterior probability that arm 1’s response rate exceeds arm 2’s. The response probability for a participant assigned to arm 1 is \(\theta_1\), which is uncertain and is not the allocation probability.

Clinical Biostats