Why Covariance Requires the Joint Density
For a continuous pair, the joint density describes how probability is distributed across combinations of values of \(X\) and \(Y\). Covariance measures whether deviations of the two variables from their respective means tend to have the same sign or opposite signs. To calculate it from a joint density, we need the two means and an integral that accounts for both variables over the actual joint support.
The support may be rectangular, triangular, or another region. It determines the integration limits: even a correct density and integrand give a wrong result if the integration region is treated as larger or smaller than the region where the density is positive.
These formulas assume the stated joint density is valid: it is nonnegative on its support, zero outside it, and integrates to one. The means and covariance integrals must also exist. In the examples below, all supports are bounded and the integrands are finite, so the required integrals exist.
From Density to Expectations
The expectation of a function of a continuous pair is calculated by weighting that function by the joint density and integrating across the support. In particular, choosing the functions \(x\), \(y\), and \(xy\) gives \(E[X]\), \(E[Y]\), and \(E[XY]\). The means can also be found by first integrating out the other variable to obtain the marginal densities.
A practical calculation usually follows a fixed order: check the density, identify the support and bounds, find the marginal means, calculate the expected product if needed, and evaluate covariance. The examples use the centered covariance integral directly, so the role of the support remains visible throughout.
Check nonnegativity and integrate the proposed density over its stated support. The total must be one.
Write the region \(D\) explicitly and express its limits in an order convenient for integration.
Integrate \(x\), \(y\), and \(xy\) against the joint density, using marginal densities for the means when convenient.
Integrate the product of centered values over the same support. Keep the computed means inside the integrand.
Worked Example: A Density on a Sloping Triangular Support
Suppose \(X\) and \(Y\) have joint density \(f_{X,Y}(x,y)=3y\) on \(0<x<y<1\), and density zero elsewhere. Verify the density and calculate the marginal means, \(E[XY]\), and \(\operatorname{Cov}(X,Y)\).
Method. The support can be written \(0<y<1\), \(0<x<y\). First verify normalization:
The density is nonnegative on the support, so it is a valid joint density. Integrating out \(y\) and \(x\), respectively, gives the marginals:
Now calculate the means from these marginals:
The expected product must be integrated over the triangular support, not over the unit square:
For covariance, substitute the two means into the centered integral:
The result is positive. As a check on the arithmetic, expanding the centered integrand gives the same value as \(3/10-(3/8)(3/4)=3/160\). The covariance is therefore \(\boxed{3/160}\).
Worked Example: Uniform Density on a Simplex
A hypothetical model has joint density \(f_{X,Y}(x,y)=2\) on \(0<x<1\), \(0<y<1-x\), and zero elsewhere. Find the means, the expected product, and the covariance. This triangular support slopes in the opposite direction from the previous example.
Method. The support is \(0<x<1\), \(0<y<1-x\). Its area is \(1/2\), so the constant density integrates to \(2(1/2)=1\). The marginal densities are
By symmetry, the means are equal; evaluating either marginal integral confirms their values:
For the expected product, integrate \(y\) from zero to \(1-x\):
Using the centered definition, integrate first with respect to \(y\):
The negative sign is consistent with the constraint \(x+y<1\): larger values of one variable leave less room for the other. As an arithmetic check, \(E[XY]=1/12\) and the product of the means is \(1/9\); their difference is \(-1/36\). The covariance is \(\boxed{-1/36}\).
A Rectangular Support with a Nonconstant Density
A rectangular support does not imply that the variables are independent. Independence requires the joint density to factor into the product of its marginals; a rectangle alone is not enough. The next example shows how a density can vary across a rectangle and produce nonzero covariance.
Worked Example: A Bilinear Density on the Unit Square
Suppose the joint density is \(f_{X,Y}(x,y)=1+\frac12(2x-1)(2y-1)\) for \(0<x<1\), \(0<y<1\), and zero elsewhere. Find the marginal means, \(E[XY]\), and covariance.
Method. On the unit square, each factor \(2x-1\) and \(2y-1\) lies between \(-1\) and \(1\). Thus the density is at least \(1/2\), hence nonnegative. Its integral is one because the integral of \(2x-1\) from zero to one is zero:
Integrating over either coordinate eliminates the product term, so \(f_X(x)=1\) and \(f_Y(y)=1\) on \((0,1)\). Therefore
For the expected product, separate the two integrals in the product term:
In the centered covariance integral, the constant-density part integrates to zero, leaving
The covariance is positive, and the check \(19/72-(1/2)(1/2)=1/72\) agrees. The joint density varies with both coordinates even though the support is a rectangle, so the support shape alone does not establish independence.
Common Support Errors and Exam Checks
The most consequential error in these calculations is often not an integration mistake but a support mistake. For example, the density \(3y\) in the first example is defined only where \(0<x<y<1\). Integrating it over the full unit square instead would give
not one. That result does not show that the stated density is invalid; it shows that the integral used the wrong region. Conversely, changing the region without changing the density can make an intended model fail normalization.
Before accepting a covariance, check that the density integrates to one on the stated support, each marginal integrates to one, and the means and product use bounds consistent with that support. Also keep the means fixed at their computed values when evaluating the centered integral. Covariance has units equal to the product of the units of \(X\) and \(Y\), so it is not itself a standardized measure of association.
- Wrong bounds: A triangular support must not be silently replaced by its enclosing rectangle.
- Missing the density in an expectation: An integral of \(xy\) alone is not \(E[XY]\); the integrand must include \(f_{X,Y}(x,y)\).
- Using a marginal where a joint integral is needed: The expected product depends on both variables and generally requires the joint density.
- Skipping normalization: A proposed formula is not a joint density unless its total probability is one.
Check Your Understanding
For each model, verify normalization where requested, identify the support bounds, and calculate the stated covariance. Answers are exact.
- A joint density is \(2\) on \(0<x<y<1\) and zero elsewhere. Verify normalization and find \(E[X]\), \(E[Y]\), \(E[XY]\), and \(\operatorname{Cov}(X,Y)\). (Answer: normalized; \(E[X]=1/3\), \(E[Y]=2/3\), \(E[XY]=1/4\), covariance \(=1/36\))
- A joint density is \(1/6\) on \(0<x<2\), \(0<y<3\), and zero elsewhere. Verify normalization and find the covariance. (Answer: normalized; covariance \(=0\))
- A joint density is \(2\) on \(0<y<x<1\) and zero elsewhere. Find both means, the expected product, and the covariance. (Answer: \(E[X]=2/3\), \(E[Y]=1/3\), \(E[XY]=1/4\), covariance \(=1/36\))
- A joint density is \(1+(2x-1)(2y-1)\) on the unit square and zero elsewhere. Verify normalization and find the covariance. (Answer: normalized; covariance \(=1/36\))
- A joint density is \(3x\) on \(0<y<x<1\) and zero elsewhere. Find the means, expected product, and covariance. (Answer: \(E[X]=3/4\), \(E[Y]=3/8\), \(E[XY]=3/10\), covariance \(=3/160\))