Why a Joint Probability Table Is Useful
A joint probability table describes the probabilities of pairs of values for two discrete random variables. Covariance calculated from that table summarizes how the variables vary together: the calculation compares each possible pair with the two variables’ marginal means and weights the comparison by the pair’s probability. The table must be read cell by cell; its row and column totals matter because they determine the marginal distributions and means.
For example, a hypothetical insurer might model the number of minor claims reported by two different coverage groups over a fixed period. A joint table could describe the two claim counts. The calculation in this tutorial uses only the probability table: no interest rate or mortality assumption is involved. The same method applies to other finite discrete models.
A valid joint probability table has nonnegative entries that sum to 1. To find the marginal probability of a value of \(X\), add the entries across that row; to find the marginal probability of a value of \(Y\), add the entries down that column. The means are then calculated from these marginal probabilities. Do not treat a cell probability as though it were a marginal probability.
A Reliable Calculation Sequence
The centered-product definition gives a direct procedure. First verify the table, then find the marginal means. Next, calculate the centered product for each cell, multiply it by that cell’s joint probability, and add the weighted products. A positive contribution comes from a cell where the two deviations from their means have the same sign; a negative contribution comes from a cell where those deviations have opposite signs. The size of each contribution also depends on the cell probability and the sizes of the deviations.
Confirm that every entry is nonnegative and that all entries sum to 1.
Add rows and columns to obtain marginal probabilities, then calculate \(E[X]\) and \(E[Y]\).
For each cell, multiply its probability by \((x_i-E[X])(y_j-E[Y])\), then sum the results.
For a finite table, compare with \(E[XY]-E[X]E[Y]\), calculated using the same joint probabilities.
Why the Table Formula Holds
For discrete variables with a finite joint table, the expected value of any function of \(X\) and \(Y\) is the sum of that function’s values weighted by the corresponding joint probabilities. Apply this rule to the function \(g(x,y)=(x-E[X])(y-E[Y])\). At the cell \((x_i,y_j)\), the function has value \((x_i-E[X])(y_j-E[Y])\), and the probability of that cell is \(p_{ij}\). Summing over every cell gives the covariance:
This derivation also explains why using the marginal probabilities as cell weights is incorrect: each centered product belongs to a particular pair \((x_i,y_j)\), whose probability is the joint probability \(p_{ij}\).
Worked Example: A Two-by-Two Joint Table
A hypothetical model assigns the following joint distribution to \(X\), the number of minor claims in one coverage group, and \(Y\), the number in another group, during the same fixed period. The support is \(X\in\{0,2\}\) and \(Y\in\{1,3\}\). The probabilities in the table specify the entire discrete distribution; no interest rate or mortality assumption applies. Find both means and the covariance.
| \(X\backslash Y\) | \(Y=1\) | \(Y=3\) | Row total |
|---|---|---|---|
| \(X=0\) | 0.2000 | 0.3000 | 0.5000 |
| \(X=2\) | 0.1000 | 0.4000 | 0.5000 |
| Column total | 0.3000 | 0.7000 | 1.0000 |
Step 1: Check the probabilities. The four entries are nonnegative and sum to \(0.2000+0.3000+0.1000+0.4000=1.0000\).
Step 2: Find the marginal means. The row totals give \(P(X=0)=0.5000\) and \(P(X=2)=0.5000\), so \(E[X]=0(0.5000)+2(0.5000)=1.0000\). The column totals give \(P(Y=1)=0.3000\) and \(P(Y=3)=0.7000\), so \(E[Y]=1(0.3000)+3(0.7000)=2.4000\).
Step 3: Sum the centered products. The deviations of \(X\) from its mean are \(-1\) and \(1\); those of \(Y\) are \(-1.4\) and \(0.6\). The four weighted contributions are:
Adding them gives \(\operatorname{Cov}(X,Y)=0.2800-0.1800-0.1400+0.2400=0.2000\).
Check and common mistake avoided. The only nonzero contributions to \(E[XY]\) come from the cells \((2,1)\) and \((2,3)\): \(E[XY]=2(1)(0.1000)+2(3)(0.4000)=0.2000+2.4000=2.6000\). Thus \(E[XY]-E[X]E[Y]=2.6000-(1.0000)(2.4000)=0.2000\), which agrees. A common mistake is to omit the \((2,1)\) cell because its contribution seems small; its \(XY\) value is not zero.
Working with Unequal Marginals
A table need not have equal row or column totals. The marginal means must reflect the actual totals, even when a variable has values that look evenly spaced. In particular, an unweighted average of the listed values is generally not the expectation. Each value is weighted by its marginal probability, which is obtained by summing the appropriate joint probabilities.
Worked Example: Unequal Column Totals
In a hypothetical discrete model, \(X\) takes values 1 and 3, and \(Y\) takes values 0, 2, and 5. The joint probability table is the specified distribution; no interest rate or mortality assumption applies. Find the marginal means and covariance.
| \(X\backslash Y\) | \(Y=0\) | \(Y=2\) | \(Y=5\) | Row total |
|---|---|---|---|---|
| \(X=1\) | 0.1000 | 0.1500 | 0.2500 | 0.5000 |
| \(X=3\) | 0.2000 | 0.1000 | 0.2000 | 0.5000 |
| Column total | 0.3000 | 0.2500 | 0.4500 | 1.0000 |
Step 1: Verify the table and calculate means. Its entries sum to \(1.0000\). The row totals give \(E[X]=1(0.5000)+3(0.5000)=2.0000\). The column totals give \(E[Y]=0(0.3000)+2(0.2500)+5(0.4500)=0+0.5000+2.2500=2.7500\).
Step 2: Calculate the centered contributions. The \(X\)-deviations are \(-1\) and \(1\); the \(Y\)-deviations, in table order, are \(-2.75\), \(-0.75\), and \(2.25\). For \(X=1\), the contributions are \(0.1000(-1)(-2.75)=0.2750\), \(0.1500(-1)(-0.75)=0.1125\), and \(0.2500(-1)(2.25)=-0.5625\). Their sum is \(-0.1750\).
For \(X=3\), the contributions are \(0.2000(1)(-2.75)=-0.5500\), \(0.1000(1)(-0.75)=-0.0750\), and \(0.2000(1)(2.25)=0.4500\). Their sum is \(-0.1750\). Therefore \(\operatorname{Cov}(X,Y)=-0.1750-0.1750=-0.3500\).
Check and common mistake avoided. Directly, \(E[XY]=1(2)(0.1500)+1(5)(0.2500)+3(2)(0.1000)+3(5)(0.2000)=0.3000+1.2500+0.6000+3.0000=5.1500\). Then \(5.1500-(2.0000)(2.7500)=-0.3500\). Do not replace the column probabilities \(0.3000,0.2500,0.4500\) with equal weights when finding \(E[Y]\).
A Three-by-Three Table
With more rows and columns, the method is unchanged. Keeping the marginal means visible helps prevent sign errors: each cell’s centered product is determined by whether its \(X\)- and \(Y\)-deviations are positive or negative.
Worked Example: Summing Nine Weighted Products
Let \(X\in\{0,1,2\}\) and \(Y\in\{0,1,2\}\) have the following joint distribution. This is a finite discrete model specified by its table; no interest rate or mortality assumption applies. Calculate \(E[X]\), \(E[Y]\), and the covariance.
| \(X\backslash Y\) | \(Y=0\) | \(Y=1\) | \(Y=2\) | Row total |
|---|---|---|---|---|
| \(X=0\) | 0.1000 | 0.0500 | 0.0500 | 0.2000 |
| \(X=1\) | 0.0500 | 0.2000 | 0.0500 | 0.3000 |
| \(X=2\) | 0.0500 | 0.1000 | 0.3500 | 0.5000 |
| Column total | 0.2000 | 0.3500 | 0.4500 | 1.0000 |
Step 1: Check the table and find the means. The entries sum to \(1.0000\). From the row totals, \(E[X]=0(0.2000)+1(0.3000)+2(0.5000)=1.3000\). From the column totals, \(E[Y]=0(0.2000)+1(0.3500)+2(0.4500)=1.2500\).
Step 2: Weight each centered product. The \(X\)-deviations are \(-1.3,-0.3,0.7\), while the \(Y\)-deviations are \(-1.25,-0.25,0.75\). Listed row by row, the nine contributions are:
The total is \(0.13000+0.02250+0.12250=0.27500\), so \(\operatorname{Cov}(X,Y)=0.2750\).
Check and common mistake avoided. The nonzero terms in \(E[XY]\) are \(1(1)(0.2000)+1(2)(0.0500)+2(1)(0.1000)+2(2)(0.3500)=0.2000+0.1000+0.2000+1.4000=1.9000\). Therefore \(E[XY]-E[X]E[Y]=1.9000-(1.3000)(1.2500)=1.9000-1.6250=0.2750\). A sign error in a centered product often comes from subtracting the mean from only one variable or using the wrong deviation for a row or column.
Common Errors and a Final Check
The centered-product calculation is reliable when each cell is treated as a pair of values with its own joint probability. Before accepting a result, check the table totals, the marginal means, and the arithmetic in every cell. The shortcut \(E[XY]-E[X]E[Y]\) is a useful independent check, but it does not excuse omitting a cell or using incorrect marginals: it must use the same valid joint distribution.
- Using cell probabilities as marginal probabilities. A row or column probability is a sum of cells, not one cell entry.
- Averaging support values without weights. The mean uses the marginal probabilities, which may be unequal.
- Dropping a nonzero product. A cell contributes to \(E[XY]\) whenever its \(XY\) value and its probability are nonzero.
- Ignoring the sign of a deviation. Calculate \(x_i-E[X]\) and \(y_j-E[Y]\) explicitly before multiplying.
- Starting with an invalid table. If the probabilities do not sum to 1, the table as given is not a joint probability distribution.
Check Your Understanding
For each table, verify the probabilities, find the marginal means, and calculate the covariance using the centered-product definition.
- \(X\) takes values 0 and 2; \(Y\) takes values \(-1\) and 2. The rows for \(X=0,2\), respectively, are \((0.3000,0.2000)\) and \((0.1000,0.4000)\). (Answer: \(E[X]=1.0000\), \(E[Y]=0.8000\), \(\operatorname{Cov}(X,Y)=0.6000\))
- \(X\) takes values 1 and 4; \(Y\) takes values 0 and 3. The rows for \(X=1,4\), respectively, are \((0.2000,0.3000)\) and \((0.1000,0.4000)\). (Answer: \(E[X]=2.5000\), \(E[Y]=2.1000\), \(\operatorname{Cov}(X,Y)=0.4500\))
- \(X\) takes values 0, 1, and 3; \(Y\) takes values 0 and 2. The rows are \((0.1000,0.2000)\), \((0.2000,0.1000)\), and \((0.1000,0.3000)\), in that order. (Answer: \(E[X]=1.5000\), \(E[Y]=1.2000\), \(\operatorname{Cov}(X,Y)=0.2000\))
- \(X\) takes values \(-1\) and 2; \(Y\) takes values 0, 1, and 4. The rows for \(X=-1,2\), respectively, are \((0.2000,0.1000,0.2000)\) and \((0.1000,0.2000,0.2000)\). (Answer: \(E[X]=0.5000\), \(E[Y]=1.9000\), \(\operatorname{Cov}(X,Y)=0.1500\))
- \(X\) takes values 0 and 2; \(Y\) takes values 1 and 4. The rows for \(X=0,2\), respectively, are \((0.1500,0.2500)\) and \((0.3500,0.2500)\). (Answer: \(E[X]=1.2000\), \(E[Y]=2.5000\), \(\operatorname{Cov}(X,Y)=-0.3000\))