ExamSaathi learning library · Government exams · SSC CGL quantitative foundations; published syllabus labelled 2024 · Quantitative aptitude

Joint distribution of two discrete random variables: marginals and independence

Read a joint probability table for two discrete random variables U and V: find a missing entry, add cells for events, get the marginal and conditional distributions, test independence cell by cell, and find E(UV), the covariance and Var(U + V).

Status: original pilot lesson. Teacher review is pending. It is not a complete course or official exam material.

You will learn to

Before you start

This lesson builds on the random-variable lesson, which finds the mean E(U) and the variance Var(U) of a single discrete random variable from its probability table; those steps are used here without being taught again. Now two random variables are recorded on the same trial, for example U = the number of stitching faults and V = the number of dye patches on one T-shirt picked from a garment unit in Tiruppur. Capital U and V name the variables, small u and v stand for particular values, and p(u, v) is short for P(U = u and V = v). The letter x always means multiply. Probabilities are written as fractions with decimals beside them, such as 3/8 = 0.375, so that each step can be checked.

The joint probability table

A joint probability table lists every pair of values that U and V can take together. Write the values of U down the side and the values of V across the top; the cell in row u and column v holds p(u, v). Every entry must lie between 0 and 1, and the entries of the whole table must total exactly 1, since one trial always yields one pair and only one. The second fact fills gaps. If five cells add up to 0.85, the sixth must be 0.15, and if the cells are written as k, 2k, 3k and so on, setting their total equal to 1 gives k. Any statement about U and V picks out a set of cells, and its chance is the sum of those cells. For U + V = 2, add every cell whose two values add up to 2, such as (0, 2), (1, 1) and (2, 0). For U > V, add the cells whose row value is bigger than their column value. A cell holding 0 is a pair that never happens.

Marginal and conditional distributions

Adding along a row gives the chance of that value of U whatever V turns out to be: P(U = u) = sum of p(u, v) over all v. Written in the right-hand margin, these row totals form the marginal distribution of U. In the same way the column totals, written along the bottom, form the marginal distribution of V. Each set of marginal totals adds up to 1, a quick check on the arithmetic, and E(U) and Var(U) come from the marginal of U exactly as for a single variable. A conditional distribution looks inside one column or one row only. Given V = v, the chance that U = u is P(U = u given V = v) = p(u, v) / P(V = v): divide each cell in that column by the column total. The results add up to 1, as any distribution must. For instance, if the column for V = 2 holds 0.06, 0.12 and 0.12, its total is 0.30, and given V = 2 the chances of U = 0, 1 and 2 are 0.2, 0.4 and 0.4.

Testing independence cell by cell

U and V are independent when knowing the value of one changes nothing about the chances for the other. In a joint table this means p(u, v) = P(U = u) x P(V = v) for every cell. To test it, multiply each row total by each column total and compare the product with the cell. If every cell matches, U and V are independent, and every conditional distribution of U is then the same as the marginal of U. If even one cell fails, U and V are dependent, and the other cells need not be checked. A 0 in a cell whose row and column totals are both above 0 fails at once, because two positive numbers cannot multiply to 0. One cell that happens to match proves nothing; a table with 3 rows and 2 columns has six products to compare. To build a table for independent variables, fill each cell with the product of its two marginals: if P(U = 1) = 0.4 and P(V = 2) = 0.5, the cell (1, 2) must hold 0.2.

Covariance and the sum U + V

The mean of the product UV is E(UV) = sum of u x v x p(u, v) over all the cells; a cell with u = 0 or v = 0 adds nothing. The covariance compares this with the product of the two means: Cov(U, V) = E(UV) - E(U) x E(V). A positive covariance says that large values of U tend to come with large values of V; a negative one says that large values of U tend to come with small values of V. For a total, the means always add: E(U + V) = E(U) + E(V), whether or not U and V are independent. The spreads need a correction term: Var(U + V) = Var(U) + Var(V) + 2 x Cov(U, V). Independent variables have E(UV) = E(U) x E(V), so their covariance is 0 and Var(U + V) = Var(U) + Var(V). The reverse does not hold: a covariance of 0 does not prove independence. The two-coin example below has covariance 0, yet one of its cells breaks the product rule.

Common mistakes

Finding k from a single row; it is the whole table, not each row, that adds up to 1. Reading the marginal of U from the column totals when U runs down the side. Dividing by the wrong total in a conditional chance: given V = v, divide by the column total P(V = v), not by a row total. Calling U and V independent after one cell matches. Taking a covariance of 0 as proof of independence. Writing E(UV) = E(U) x E(V) without first knowing that U and V are independent. Leaving out 2 x Cov(U, V) in Var(U + V), or adding the covariance only once. Missing a cell when adding up an event such as U + V = 2, especially a cell at the edge of the table.

A routine for joint tables

1. Set out the table with U down the side and V across the top, and check that all the cells add up to 1; use this to find a missing cell or k. 2. Write the row totals and column totals: these are the marginal distributions. 3. For an event, list the cells it covers and add them. 4. For a conditional chance, divide the cell by the total of the row or column that is given. 5. For independence, compare every cell with row total x column total; a single mismatch means dependent. 6. Find E(U) and E(V) from the marginals and E(UV) from the cells, then Cov(U, V) = E(UV) - E(U) x E(V). 7. Use E(U + V) = E(U) + E(V) and Var(U + V) = Var(U) + Var(V) + 2 x Cov(U, V).

Worked examples

  1. Two fair coins are tossed. Let U be the number of heads, and let V = 1 if the two coins show the same face and V = 0 if they differ. Build the joint table of U and V, find both marginal distributions, decide whether U and V are independent, and find Cov(U, V).

    1. The four equally likely outcomes give: HH, so U = 2 and V = 1; HT and TH, so U = 1 and V = 0; TT, so U = 0 and V = 1.
    2. Joint table, rows U = 0, 1, 2 and columns V = 0, 1: U = 0 has 0 and 1/4; U = 1 has 1/2 and 0; U = 2 has 0 and 1/4. The six cells add up to 1.
    3. Row totals give the marginal of U: P(U = 0) = 1/4 = 0.25, P(U = 1) = 1/2 = 0.5, P(U = 2) = 1/4 = 0.25. Column totals give the marginal of V: P(V = 0) = 1/2 = 0.5 and P(V = 1) = 1/2 = 0.5.
    4. Independence test: p(0, 0) = 0, but P(U = 0) x P(V = 0) = 1/4 x 1/2 = 1/8 = 0.125. One failing cell settles it: U and V are dependent.
    5. E(U) = 0 x 0.25 + 1 x 0.5 + 2 x 0.25 = 1 and E(V) = 0.5. In E(UV) only the cell (2, 1) has both a non-zero product and a non-zero chance, so E(UV) = 2 x 1 x 1/4 = 1/2 = 0.5.
    6. Cov(U, V) = E(UV) - E(U) x E(V) = 0.5 - 1 x 0.5 = 0.

    Answer: U and V are dependent, because p(0, 0) = 0 while the product of its marginals is 1/8 = 0.125; yet Cov(U, V) = 0, so a zero covariance does not prove independence.

  2. A checker at a garment unit in Tiruppur records, for each T-shirt, U = the number of stitching faults (0, 1 or 2) and V = the number of dye patches (0 or 1). The joint table is: U = 0: p(0, 0) = 0.30, p(0, 1) = 0.10; U = 1: p(1, 0) = 0.20, p(1, 1) = k; U = 2: p(2, 0) = 0.10, p(2, 1) = 0.15. Find k, P(U > V), P(U + V = 2) and the conditional distribution of U given V = 1, and decide whether U and V are independent.

    1. All six cells add up to 1: 0.30 + 0.10 + 0.20 + k + 0.10 + 0.15 = 0.85 + k = 1, so k = 0.15.
    2. U > V covers the cells (1, 0), (2, 0) and (2, 1): 0.20 + 0.10 + 0.15 = 0.45.
    3. U + V = 2 covers the cells (2, 0) and (1, 1): 0.10 + 0.15 = 0.25.
    4. Row totals: P(U = 0) = 0.40, P(U = 1) = 0.35, P(U = 2) = 0.25. Column totals: P(V = 0) = 0.60, P(V = 1) = 0.40.
    5. Given V = 1, divide that column by 0.40: P(U = 0 given V = 1) = 0.10 / 0.40 = 1/4 = 0.25, P(U = 1 given V = 1) = 0.15 / 0.40 = 3/8 = 0.375 and P(U = 2 given V = 1) = 0.15 / 0.40 = 3/8 = 0.375, which add up to 1.
    6. Independence test: p(0, 0) = 0.30, but P(U = 0) x P(V = 0) = 0.40 x 0.60 = 0.24, so U and V are dependent.

    Answer: k = 0.15, P(U > V) = 0.45 and P(U + V = 2) = 0.25; given V = 1, U = 0, 1 and 2 have chances 0.25, 0.375 and 0.375; U and V are dependent, since 0.30 is not 0.24.

  3. In a survey of families in a Kerala village that own at least one two-wheeler, U = the number of two-wheelers (1 or 2) and V = the number of smartphones (0, 1 or 2). The joint table is: U = 1: p(1, 0) = 0.1, p(1, 1) = 0.2, p(1, 2) = 0.1; U = 2: p(2, 0) = 0.1, p(2, 1) = 0.1, p(2, 2) = 0.4. Find E(UV), Cov(U, V), E(U + V) and Var(U + V).

    1. Marginal of U: P(U = 1) = 0.4 and P(U = 2) = 0.6, so E(U) = 0.4 + 1.2 = 1.6, E(U^2) = 0.4 + 2.4 = 2.8 and Var(U) = 2.8 - 1.6^2 = 0.24.
    2. Marginal of V: P(V = 0) = 0.2, P(V = 1) = 0.3, P(V = 2) = 0.5, so E(V) = 0.3 + 1.0 = 1.3, E(V^2) = 0.3 + 2.0 = 2.3 and Var(V) = 2.3 - 1.3^2 = 0.61.
    3. E(UV) = 1 x 1 x 0.2 + 1 x 2 x 0.1 + 2 x 1 x 0.1 + 2 x 2 x 0.4 = 0.2 + 0.2 + 0.2 + 1.6 = 2.2; the cells with V = 0 add nothing.
    4. Cov(U, V) = 2.2 - 1.6 x 1.3 = 2.2 - 2.08 = 0.12. It is positive: families with two two-wheelers tend to own more smartphones.
    5. E(U + V) = 1.6 + 1.3 = 2.9 and Var(U + V) = 0.24 + 0.61 + 2 x 0.12 = 1.09.
    6. Direct check: U + V takes the values 1, 2, 3 and 4 with chances 0.1, 0.3, 0.2 and 0.4, so its mean is 0.1 + 0.6 + 0.6 + 1.6 = 2.9 and E((U + V)^2) = 0.1 + 1.2 + 1.8 + 6.4 = 9.5, giving 9.5 - 2.9^2 = 1.09.

    Answer: E(UV) = 2.2, Cov(U, V) = 0.12, E(U + V) = 2.9 and Var(U + V) = 1.09.

Practice checks

  1. U takes the values 0, 1 and 2, and V takes the values 0 and 1. Their joint table has p(0, 0) = 2k, p(0, 1) = k, p(1, 0) = k, p(1, 1) = 3k, p(2, 0) = 2k and p(2, 1) = k. What is P(U > V)?
  2. A joint table has p(0, 0) = 0.10, p(0, 1) = 0.05, p(1, 0) = 0.25, p(1, 1) = 0.15, p(2, 0) = 0.35 and p(2, 1) = 0.10. What is P(U = 1 given V = 1)?
  3. U and V each take the values 0 and 1. Their joint table has p(0, 0) = 0.12 and p(0, 1) = 0.28, and the other two cells are not yet filled in. What value of p(1, 1) makes U and V independent?
  4. At a sweet shop in Surat, U = 1 if a visitor buys sweets (0 if not) and V = 1 if the visitor buys namkeen (0 if not). The joint table is p(0, 0) = 0.2, p(0, 1) = 0.3, p(1, 0) = 0.1 and p(1, 1) = 0.4. What is Cov(U, V)?
  5. At a call centre in Gurugram, U and V are the numbers of calls two agents answer in an hour from one shared queue, with Var(U) = 4, Var(V) = 9 and Cov(U, V) = -1.5. What is the variance of the total number of calls, U + V?

Sources checked