St · Statistics & Probability

How to Calculate E[XY] for Dependent Random Variables

Updated 13 October 2026

At a glance

  1. 1. Find the joint behavior

    Use the joint distribution, or a conditional distribution together with the distribution of one variable.

  2. 2. Calculate the product mean

    Average each product xy using its joint probability, or integrate xy against the joint density.

  3. 3. Use covariance if known

    When the covariance and both means are known, add the covariance to the product of the means.

  4. 4. Check dependence assumptions

    Multiply the means only when independence or another condition that gives zero covariance is justified.

If XX and YY are dependent, their product’s expected value is not usually the product of their expected values. To calculate E[XY]\mathbb{E}[XY], you need information about how the variables occur together, such as their joint distribution or their covariance.

The key relationship is E[XY]=E[X]E[Y]+Cov⁡(X,Y)\mathbb{E}[XY]=\mathbb{E}[X]\mathbb{E}[Y]+\operatorname{Cov}(X,Y), when the relevant expectations and covariance exist. The covariance term accounts for how dependence changes the average product.

Calculate the expectation from the joint distribution

For discrete random variables with joint probability mass function pX,Y(x,y)p_{X,Y}(x,y),

E[XY]=∑x∑yxy pX,Y(x,y).\mathbb{E}[XY]=\sum_x\sum_y xy\,p_{X,Y}(x,y).

Each possible pair (x,y)(x,y) contributes its product, weighted by the probability that the pair occurs. For continuous variables with joint density fX,Y(x,y)f_{X,Y}(x,y), the corresponding formula is

E[XY]=∫−∞∞∫−∞∞xyfX,Y(x,y) dx dy,\mathbb{E}[XY]=\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}xy f_{X,Y}(x,y)\,dx\,dy,

provided the expectation is defined. In either case, it is the joint distribution that matters. The marginal distributions describe XX and YY separately, but do not necessarily say how their values are paired.

If the covariance is available instead, use its definition:

Cov⁡(X,Y)=E[XY]−E[X]E[Y].\operatorname{Cov}(X,Y)=\mathbb{E}[XY]-\mathbb{E}[X]\mathbb{E}[Y].

Rearranging gives

E[XY]=E[X]E[Y]+Cov⁡(X,Y).\mathbb{E}[XY]=\mathbb{E}[X]\mathbb{E}[Y]+\operatorname{Cov}(X,Y).

This identity applies when, for example, both variables have finite second moments. More generally, check that the expectations in the expression you use exist.

Why the marginal means are not enough

If XX and YY are independent and their expectations exist, then Cov⁡(X,Y)=0\operatorname{Cov}(X,Y)=0, so

E[XY]=E[X]E[Y].\mathbb{E}[XY]=\mathbb{E}[X]\mathbb{E}[Y].

But dependence alone does not tell you the value of the covariance. It could be positive, negative, or zero. In particular, zero covariance does not in general prove independence; it means only that the variables are uncorrelated.

For example, knowing that both variables are Bernoulli with probability 1/21/2 gives their separate means, but not E[XY]\mathbb{E}[XY]. If they always take the same value, the product is 1 half the time. If they are independent, the product is 1 only when both are 1, which occurs with probability 1/4. The marginals match in both cases, but the expected products differ.

Worked example: dependent Bernoulli variables

Suppose XX and YY have the following joint distribution:

XXYYProbability
001/21/2
111/21/2

Here, Y=XY=X, so the variables are dependent. Compute each mean:

E[X]=0⋅12+1⋅12=12,E[Y]=12.\mathbb{E}[X]=0\cdot\frac12+1\cdot\frac12=\frac12, \qquad \mathbb{E}[Y]=\frac12.

For the product, the pair (0,0)(0,0) contributes 0 and the pair (1,1)(1,1) contributes 1:

E[XY]=0⋅12+1⋅12=12.\mathbb{E}[XY]=0\cdot\frac12+1\cdot\frac12=\frac12.

The product of the means is instead E[X]E[Y]=1/4\mathbb{E}[X]\mathbb{E}[Y]=1/4. The difference is the covariance:

Cov⁡(X,Y)=12−14=14.\operatorname{Cov}(X,Y)=\frac12-\frac14=\frac14.

Now keep the same Bernoulli marginals but make XX and YY independent. Each pair (0,0)(0,0), (0,1)(0,1), (1,0)(1,0), and (1,1)(1,1) then has probability 1/41/4. Only (1,1)(1,1) contributes to XYXY, giving E[XY]=1/4\mathbb{E}[XY]=1/4. This comparison shows why separate means cannot determine the expected product.

Use conditional expectation when it is easier

Sometimes the joint distribution is cumbersome, but the conditional mean of one variable given the other is simple. The law of iterated expectation gives

E[XY]=E[X E(Y∣X)],\mathbb{E}[XY]=\mathbb{E}\big[X\,\mathbb{E}(Y\mid X)\big],

assuming the product is integrable. In the dependent Bernoulli example, Y=XY=X, so E(Y∣X)=X\mathbb{E}(Y\mid X)=X. Therefore,

E[XY]=E[X2]=12,\mathbb{E}[XY]=\mathbb{E}[X^2]=\frac12,

since X2=XX^2=X when XX is either 0 or 1. This method is useful when you know a conditional model such as E(Y∣X=x)\mathbb{E}(Y\mid X=x) and the distribution of XX.

Common mistakes

  • Multiplying the means without checking independence. This gives the expected product only under independence (or another condition that makes the covariance zero).
  • Treating dependence as a numerical answer. Knowing that variables are dependent does not reveal the sign or size of their covariance.
  • Assuming zero covariance means independence. Some dependent variables have zero covariance; independence is a stronger property.
  • Using only the marginal distributions. To compute the product expectation in general, you need their joint behavior or equivalent information, such as covariance together with both means.

References

  1. A First Course in Probability, Sheldon Ross

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.