Why Centered Products Matter
When two random variables are observed together, their outcomes can tend to fall on the same side of their respective means, or on opposite sides. Covariance summarizes that pattern by multiplying the deviations from the means for each paired outcome and taking an expectation. The centering step matters: it makes the calculation about departures from typical values, rather than about the raw sizes of the variables.
For an actuarial analyst, a joint distribution might describe two features recorded on the same hypothetical policy, claim, or operating period. The marginal distributions tell us about each variable separately; covariance uses the paired outcomes to describe how their deviations occur together. This tutorial focuses on the definition and direct calculation from a joint distribution.
The definition requires the joint behavior of \(X\) and \(Y\), not just their separate ranges. For discrete variables, if the possible paired outcomes are \((x_i,y_j)\) with joint probabilities \(p_{ij}=P(X=x_i,Y=y_j)\), then
Only pairs with positive probability contribute to the sum. The means must be found from the joint distribution’s marginal probabilities: for example, \(P(X=x_i)\) is obtained by adding the probabilities of all joint outcomes having that \(X\)-value. For continuous variables with joint density \(f_{X,Y}(x,y)\), the corresponding expectation is an integral of the centered product against that density, provided the moments exist.
How to Calculate Covariance from a Joint Distribution
A reliable procedure keeps the centering visible throughout the calculation. First calculate both means. Then, for each possible pair of outcomes, subtract the appropriate mean from each coordinate, multiply those two deviations, and weight the product by that pair’s probability. Finally, add the weighted products. Do not center one variable using the other variable’s mean: each variable is centered at its own mean.
Use the joint probabilities to obtain the marginal distribution of each variable, then take its expected value.
For an outcome \((x,y)\), calculate \(x-E[X]\) and \(y-E[Y]\) separately.
Multiply the two deviations for each pair, multiply that result by the pair’s joint probability, and sum.
Worked Calculations
Worked Example: Positively Aligned Audit Counts
A hypothetical audit records \(X\), the number of minor exceptions, and \(Y\), the number of follow-up checks required on a selected file. The discrete joint distribution is:
| \(X\) | \(Y\) | Joint probability |
|---|---|---|
| 0 | 1 | 0.10 |
| 0 | 3 | 0.10 |
| 2 | 1 | 0.10 |
| 2 | 3 | 0.70 |
Find \(\operatorname{Cov}(X,Y)\). The probabilities sum to \(0.10+0.10+0.10+0.70=1.00\), so they define a probability distribution. This is a hypothetical discrete model; no interest rate or mortality assumption is involved.
Step 1: Find the means. The marginal probabilities for \(X\) are \(P(X=0)=0.10+0.10=0.20\) and \(P(X=2)=0.10+0.70=0.80\). Thus \(E[X]=0(0.20)+2(0.80)=1.60\). For \(Y\), \(P(Y=1)=0.10+0.10=0.20\) and \(P(Y=3)=0.10+0.70=0.80\), so \(E[Y]=1(0.20)+3(0.80)=2.60\).
Step 2: Center, multiply, and weight. For \((0,1)\), the deviations are \(-1.60\) and \(-1.60\), giving product \(2.56\), weighted contribution \(2.56(0.10)=0.256\). For \((0,3)\), the deviations are \(-1.60\) and \(0.40\), giving product \(-0.64\), weighted contribution \(-0.064\). For \((2,1)\), the deviations are \(0.40\) and \(-1.60\), again giving product \(-0.64\), weighted contribution \(-0.064\). For \((2,3)\), the deviations are \(0.40\) and \(0.40\), giving product \(0.16\), weighted contribution \(0.112\).
Step 3: Sum the contributions. \(0.256-0.064-0.064+0.112=0.240\). Therefore, \(\operatorname{Cov}(X,Y)=0.240\) exception-check products. The positive result is consistent with the high-probability pair \((2,3)\), where both variables are above their means. The calculation is checked by confirming that all four joint probabilities were used and that their weighted contributions sum to \(0.240\).
Method and mistake avoided: This is the direct expected-centered-product method. The means are calculated first, and both coordinates of each pair are centered before multiplication; multiplying the raw counts instead would not give covariance.
Worked Example: Oppositely Aligned Workload Measures
For a hypothetical processing period, let \(X\) be the number of hours devoted to a special review and \(Y\) the number of routine files completed. Suppose the discrete joint distribution is:
| \(X\) (hours) | \(Y\) (files) | Joint probability |
|---|---|---|
| 1 | 10 | 0.30 |
| 1 | 4 | 0.20 |
| 5 | 10 | 0.20 |
| 5 | 4 | 0.30 |
Calculate the covariance. The probabilities add to \(0.30+0.20+0.20+0.30=1\). The model is a hypothetical discrete distribution; no interest rate or mortality assumption applies.
Step 1: Calculate the means. Each \(X\)-value has marginal probability \(0.50\), so \(E[X]=1(0.50)+5(0.50)=3\) hours. For \(Y\), \(P(Y=10)=0.30+0.20=0.50\) and \(P(Y=4)=0.20+0.30=0.50\), giving \(E[Y]=10(0.50)+4(0.50)=7\) files.
Step 2: Calculate each centered contribution. For \((1,10)\), the deviations are \(-2\) hours and \(3\) files; their product is \(-6\), and the weighted contribution is \(-6(0.30)=-1.8\). For \((1,4)\), the deviations are \(-2\) and \(-3\); the product is \(6\), and the weighted contribution is \(6(0.20)=1.2\). For \((5,10)\), the deviations are \(2\) and \(3\); the product is \(6\), and the weighted contribution is \(6(0.20)=1.2\). For \((5,4)\), they are \(2\) and \(-3\); the product is \(-6\), and the weighted contribution is \(-6(0.30)=-1.8\).
Step 3: Add. The total is \(-1.8+1.2+1.2-1.8=-1.2\). Hence \(\operatorname{Cov}(X,Y)=-1.2\) hour-files. The negative sign matches the larger probabilities on pairs where one variable is below its mean while the other is above. Checking the four probability weights confirms they sum to 1 and all four centered products have been included.
Method and mistake avoided: The calculation uses the joint probabilities of the paired workload outcomes. Treating the two marginal distributions as though they specified which outcomes occur together would discard the pairing information needed for covariance.
Worked Example: A Three-Level Variable and a Two-Level Variable
A hypothetical monitoring study records \(X\), a category coded as a numerical score with possible values \(0,1,3\), and \(Y\), a second score with possible values \(0,2\). The joint distribution is:
| \(X\) | \(Y\) | Joint probability |
|---|---|---|
| 0 | 0 | 0.20 |
| 0 | 2 | 0.10 |
| 1 | 0 | 0.20 |
| 1 | 2 | 0.30 |
| 3 | 0 | 0.10 |
| 3 | 2 | 0.10 |
Find the covariance in score-units squared. The six probabilities sum to \(1.00\); this is a hypothetical discrete model, with no interest or mortality assumption.
Step 1: Find \(E[X]\). The marginal probabilities are \(P(X=0)=0.20+0.10=0.30\), \(P(X=1)=0.20+0.30=0.50\), and \(P(X=3)=0.10+0.10=0.20\). Thus \(E[X]=0(0.30)+1(0.50)+3(0.20)=1.10\).
Step 2: Find \(E[Y]\). The marginal probabilities are \(P(Y=0)=0.20+0.20+0.10=0.50\) and \(P(Y=2)=0.10+0.30+0.10=0.50\). Therefore \(E[Y]=0(0.50)+2(0.50)=1.00\).
Step 3: Center each pair and weight its product. For \((0,0)\), the deviations are \(-1.10\) and \(-1.00\); the product is \(1.10\), contributing \(1.10(0.20)=0.220\). For \((0,2)\), they are \(-1.10\) and \(1.00\); the product is \(-1.10\), contributing \(-0.110\). For \((1,0)\), they are \(-0.10\) and \(-1.00\); the product is \(0.10\), contributing \(0.020\). For \((1,2)\), they are \(-0.10\) and \(1.00\); the product is \(-0.10\), contributing \(-0.030\). For \((3,0)\), they are \(1.90\) and \(-1.00\); the product is \(-1.90\), contributing \(-0.190\). For \((3,2)\), they are \(1.90\) and \(1.00\); the product is \(1.90\), contributing \(0.190\).
Step 4: Sum and check. The contributions total \(0.220-0.110+0.020-0.030-0.190+0.190=0.100\). Thus \(\operatorname{Cov}(X,Y)=0.100\) score-units squared. The result checks against the full list of six outcomes: their probabilities sum to 1, and their weighted centered products sum to \(0.100\).
Method and mistake avoided: This calculation finds marginal means from the joint law, then uses each of the six paired outcomes. Using only the most likely pair, or centering the values at convenient round numbers rather than their actual means, would omit required contributions or change the quantity being calculated.
Why the Definition Works
For a discrete joint distribution, the expectation of any function of the outcomes is the sum of that function’s value at each outcome, weighted by the outcome’s probability. Apply that definition to the function \(g(x,y)=(x-E[X])(y-E[Y])\). At the pair \((x_i,y_j)\), its value is exactly the product of the two deviations. Weighting these values by \(p_{ij}\) and adding gives:
This is the direct discrete calculation of the defining expectation, not a different quantity. The centering makes each product reflect how the two variables depart from their own averages on that particular outcome. If both deviations are positive, or both are negative, their product is positive. If one is positive and the other negative, their product is negative. The covariance is the probability-weighted balance of all these contributions.
Common Exam Trap: Using Raw Products
A frequent error is to calculate a weighted average of \(XY\) and label it covariance. In the audit example, \(XY\) is nonzero only for the pair \((2,3)\), so its expected value is \(6(0.70)=4.20\). But \(4.20\) is a raw-product expectation, not the covariance. The actual covariance is \(0.240\), found by first subtracting \(E[X]=1.60\) and \(E[Y]=2.60\) from each coordinate, then averaging the products of those deviations.
Another error is to calculate both means correctly but forget a low-probability row in the final sum. A useful check is to list every possible pair with positive probability, record its probability and centered product, and verify that the probability column sums to 1. The covariance has units equal to the product of the units of \(X\) and \(Y\); it is not automatically a probability or a percentage.
Check Your Understanding
For each discrete joint law, calculate the covariance by centering both variables at their means. Assume each stated list is the complete probability distribution; no interest rate or mortality assumption is involved.
- The paired outcomes \((X,Y)\) are \((0,1)\) with probability \(0.50\) and \((2,3)\) with probability \(0.50\). Find \(\operatorname{Cov}(X,Y)\). (Answer: \(1\))
- The outcomes are \((0,0),(0,4),(2,0),(2,4)\), each with probability \(0.25\). Find \(\operatorname{Cov}(X,Y)\). (Answer: \(0\))
- The outcomes are \((1,2)\) with probability \(0.20\), \((1,6)\) with probability \(0.30\), \((4,2)\) with probability \(0.10\), and \((4,6)\) with probability \(0.40\). Find \(\operatorname{Cov}(X,Y)\). (Answer: \(0.60\))
- The outcomes are \((0,5)\) with probability \(0.20\), \((2,1)\) with probability \(0.50\), and \((4,3)\) with probability \(0.30\). Find both means and then the covariance. (Answer: \(E[X]=2.2,\ E[Y]=2.4,\ \operatorname{Cov}(X,Y)=-0.68\))