Why Generalized Urn Updates Need an Audit
A generalized urn calculation can go wrong even when the arithmetic in each line is correct. Common errors include removing the drawn ball without returning it, adding the column for the wrong response or treatment, and treating proportions as though they were ball counts. These mistakes change the urn state and therefore change later allocation probabilities. A reliable audit starts by writing down what the state represents and what the replacement matrix records.
Throughout this tutorial, the urn contains balls of different treatment colors. Its state is a column vector of nonnegative ball counts. A ball is drawn with probability proportional to its color's count; after the participant's response is observed, the drawn ball is returned and the relevant replacement balls are added. The response-specific replacement matrix records the additional balls, not the ball that was drawn and returned.
If the urn state is \(Y_n=(y_{n,A},y_{n,B})^\mathsf{T}\), the next allocation probabilities are \(y_{n,A}/(y_{n,A}+y_{n,B})\) and \(y_{n,B}/(y_{n,A}+y_{n,B})\). These are probabilities for the next draw, not replacement instructions. Counts determine the urn state; proportions are calculated from the state when a draw probability is needed.
The update formula is conditional on the observed draw and response. To calculate the probability of that event as well, suppose \(q_{r\mid i}\) is the probability of response \(r\) after treatment \(i\). Then the probability of drawing \(i\) and observing response \(r\), given state \(Y_n\), is $$ \frac{y_{n,i}}{\sum_j y_{n,j}}q_{r\mid i}. $$ This probability affects how likely the state transition is, but it does not change which matrix column supplies the added balls.
Worked Error 1: Omitting the Returned Ball
Worked Example: Keeping the Drawn Ball in the State
Suppose the current state is \(Y_n=(4,3)^\mathsf{T}\), with rows and columns ordered \(A,B\). Treatment \(B\) is drawn and the response is success. The success matrix is $$ D^{(S)}=\begin{pmatrix}2&1\\0&3\end{pmatrix}. $$ Assume that the counts are the current numbers of balls, the draw is proportional to those counts, and this matrix gives additional balls after the drawn ball is returned.
Step 1: Select the column. Since treatment \(B\) was drawn, use the second column: $$ D^{(S)}e_B=\begin{pmatrix}1\\3\end{pmatrix}. $$
Step 2: Add the additional balls to the current state. The drawn \(B\) ball is returned, so the starting state remains \((4,3)^\mathsf{T}\). Thus $$ Y_{n+1}=\begin{pmatrix}4\\3\end{pmatrix}+\begin{pmatrix}1\\3\end{pmatrix} =\begin{pmatrix}5\\6\end{pmatrix}. $$ The total increases from \(7\) to \(11\), an increase of \(1+3=4\), matching the selected column's sum.
A common incorrect calculation subtracts the drawn \(B\) ball and then adds the matrix column: $$ \begin{pmatrix}4\\3\end{pmatrix}-\begin{pmatrix}0\\1\end{pmatrix} +\begin{pmatrix}1\\3\end{pmatrix} =\begin{pmatrix}5\\5\end{pmatrix}. $$ That state has total \(10\), one ball fewer than required. The next-draw probability of \(A\) is \(5/11\), approximately \(0.4545\), under the correct update; the erroneous state gives \(5/10=0.5000\). The discrepancy is not a rounding issue: it results from omitting the return.
Worked Error 2: Applying the Wrong Response Matrix
Worked Example: Matching the Matrix to the Observed Response
Let the current state be \(Y_n=(3,2)^\mathsf{T}\), and suppose treatment \(A\) is drawn. The matrices for success and failure are $$ D^{(S)}=\begin{pmatrix}2&1\\1&2\end{pmatrix}, \qquad D^{(F)}=\begin{pmatrix}0&2\\4&1\end{pmatrix}. $$ The drawn ball is returned under either response, and each matrix gives additional balls. Suppose the observed response is failure.
Correct update. Use the failure matrix and the column for drawn treatment \(A\): $$ D^{(F)}e_A=\begin{pmatrix}0\\4\end{pmatrix}, \qquad Y_{n+1}=\begin{pmatrix}3\\2\end{pmatrix}+\begin{pmatrix}0\\4\end{pmatrix} =\begin{pmatrix}3\\6\end{pmatrix}. $$ The total rises from \(5\) to \(9\), matching the failure-column sum \(0+4=4\). The next-draw probability of \(A\) is \(3/9=1/3\).
Incorrect response matrix. If the success matrix is used instead, its \(A\) column is \((2,1)^\mathsf{T}\), giving $$ \begin{pmatrix}3\\2\end{pmatrix}+\begin{pmatrix}2\\1\end{pmatrix} =\begin{pmatrix}5\\3\end{pmatrix}. $$ This produces a next-draw probability of \(A\) equal to \(5/8=0.6250\). The arithmetic is internally consistent for a success, but the observed response was failure. The matrix must be selected by response first, then by the treatment drawn.
Worked Error 3: Normalizing Before Replacing
Worked Example: Updating Counts Before Computing Proportions
Suppose the urn state is \(Y_n=(2,3)^\mathsf{T}\), treatment \(A\) is drawn, and success is observed. The success matrix has \(A\) column \((2,1)^\mathsf{T}\). Assume these entries are numbers of additional balls and the drawn ball is returned.
The correct calculation uses counts throughout the update: $$ Y_{n+1}=\begin{pmatrix}2\\3\end{pmatrix} +\begin{pmatrix}2\\1\end{pmatrix} =\begin{pmatrix}4\\4\end{pmatrix}. $$ The updated total is \(8\), and the next-draw probabilities are \(4/8=0.5000\) for \(A\) and \(4/8=0.5000\) for \(B\).
An incorrect calculation first converts the starting counts to proportions, \((2/5,3/5)^\mathsf{T}=(0.4,0.6)^\mathsf{T}\), and then adds the ball counts: $$ \begin{pmatrix}0.4\\0.6\end{pmatrix}+\begin{pmatrix}2\\1\end{pmatrix} =\begin{pmatrix}2.4\\1.6\end{pmatrix}. $$ Normalizing this mixture gives an apparent \(A\) probability of \(2.4/(2.4+1.6)=0.6000\), not the correct \(0.5000\). The calculation combined proportions with counts, which have different units. Normalize only after the count update, when the goal is to calculate draw probabilities.
Why the Total-Size Check Works
A quick check follows directly from the state-update formula. Let \(\mathbf{1}\) be a vector of ones of the appropriate length. The total number of balls before the update is \(\mathbf{1}^\mathsf{T}Y_n\). If treatment \(i\) is drawn and response \(r\) occurs, then $$ \mathbf{1}^\mathsf{T}Y_{n+1} =\mathbf{1}^\mathsf{T}(Y_n+D^{(r)}e_i) =\mathbf{1}^\mathsf{T}Y_n+\mathbf{1}^\mathsf{T}D^{(r)}e_i. $$ The last term is the sum of the selected matrix column. Therefore the total must increase by exactly the number of additional balls in that column. This check detects many errors, including omitted returns, use of the wrong column, and arithmetic mistakes. It cannot by itself prove that the chosen response matrix is correct: a wrong matrix can still produce a total matching its own column sum.
A second check concerns the allocation probabilities. After the update, divide every count by the same updated total. The resulting probabilities must be nonnegative and sum to 1. This verifies the normalization step, but it does not establish that the underlying counts were updated correctly. The checks are complementary: first validate the state transition, then calculate probabilities from that state.
Write the current count vector and identify the treatment color actually drawn. Keep the counts as counts.
Select the matrix for the response that occurred, then select the column for the treatment drawn.
Add the selected column to the current state. Check that the total changes by the sum of that column.
Divide the updated counts by their updated total, and verify that the resulting probabilities sum to 1.
Choosing a Calculation Check
For a single realized draw and response, direct vector addition is usually the clearest way to calculate the next state. Independent bookkeeping can serve as a useful check: list the returned ball and the additional balls separately, then confirm that this gives the same state. For a short sequence with several possible draws and responses, path enumeration can check whether transition probabilities and states have been assigned consistently. Simulation can reveal a coding discrepancy across many generated paths, but agreement in a simulation does not prove that a specific update is correct.
| Approach | Useful check | What it does not guarantee |
|---|---|---|
| Direct vector update | Confirms the selected column is added to the stated count vector. | Does not catch a wrongly selected response matrix unless the response is checked separately. |
| Separate return-and-add bookkeeping | Shows explicitly that the drawn ball remains in the urn and the matrix entries are additional balls. | Can repeat the same matrix-selection error as the direct calculation. |
| Short path enumeration | Checks that each possible next state and its probability correspond to the specified draw and response. | Can be cumbersome as the number of paths grows, and cannot fix an incorrect model specification. |
| Simulation | Can help expose a mismatch between an implementation and hand-calculated small cases. | Approximate agreement is not proof; a systematic coding error may persist in every simulated path. |
Diagnostics, Limits, and a Common Pitfall
When an update looks suspicious, inspect the state before looking at the resulting allocation probabilities. Check that the current state is a vector of counts, that the response matches the selected matrix, and that the treatment drawn matches the selected column. Then verify the updated entries and total. A negative count, a non-integer count when all additions are integer, or a probability outside \([0,1]\) signals a problem under the count-based setup described here. A probability sum different from 1 signals a normalization or arithmetic error.
These diagnostics have limits. A correct total does not establish that the right color counts were added. A valid probability vector does not establish that it came from the correct urn state. And a plausible-looking state does not establish that the replacement matrices encode the intended design rule. The present checks diagnose calculation errors conditional on the stated matrix convention; if the matrices themselves are specified incorrectly, the state arithmetic can be flawless while the modeled urn is still wrong.
Common mistake: “I removed the drawn ball because it left the urn during the draw, then added the replacement column.” That reasoning omits the return when the matrix entries represent additional balls after return. Under the convention used here, the draw is temporary: the drawn ball returns, and the update is \(Y_{n+1}=Y_n+D^{(r)}e_i\). Subtracting \(e_i\) is appropriate only in a different, explicitly defined convention where the ball is not returned or the matrix records a net change that already accounts for its removal.
Check Your Understanding
For each problem, identify the correct state update and use the stated convention that the drawn ball is returned before the matrix entries are added.
- The state is \((5,1)^\mathsf{T}\). Treatment \(B\) is drawn, and the observed response's \(B\) column is \((2,0)^\mathsf{T}\). What is the updated state, total, and next-draw probability of \(A\)?
- The current state is \((2,4)^\mathsf{T}\). Treatment \(A\) is drawn and failure occurs. The failure matrix's \(A\) column is \((1,3)^\mathsf{T}\), while the success matrix's \(A\) column is \((0,2)^\mathsf{T}\). Which state is correct, and what error gives the other state?
- A calculation changes state \((3,2)^\mathsf{T}\) to \((3,6)^\mathsf{T}\) after selecting a matrix column. What must the selected column sum to? What is the next-draw probability of \(B\)?
- Explain why adding a replacement column to a vector of proportions is invalid when the column entries are numbers of balls.
Solutions. (1) Add the specified column to the current state: \((5,1)^\mathsf{T}+(2,0)^\mathsf{T}=(7,1)^\mathsf{T}\). The total is \(8\), and the next-draw probability of \(A\) is \(7/8=0.8750\). (2) The observed response is failure, so use its \(A\) column: \((2,4)^\mathsf{T}+(1,3)^\mathsf{T}=(3,7)^\mathsf{T}\). The other state, \((2,6)^\mathsf{T}\), results from incorrectly using the success column. (3) The total rises from \(5\) to \(9\), so the selected column must sum to \(9-5=4\). The updated probability of \(B\) is \(6/9=2/3\), approximately \(0.6667\). (4) Proportions are dimensionless fractions, whereas the matrix entries count balls. Adding them mixes different units and does not represent an urn state. Add counts first, then divide by the updated total to obtain proportions.