Machine Learning & Signals Learning
3 Two Random Variables
3.1 Discrete Random Variables
3.1.1 Joint Characterization
Joint PDF: The probability that the experiment yields the pair of values \((X=x_k,\,Y=y_j)\) is
\(\seteqnumber{0}{3.}{0}\)\begin{equation} \label {eq:rand2:joint_pdf} p_{XY}[x_k,y_j] = \Pr [X=x_k,\,Y=y_j], \end{equation}
defined for every possible index pair \((j,k)\). The pair of values is the intersection of two events, \(\left \lbrace X=x_k\right \rbrace \cap \left \lbrace Y=y_j\right \rbrace \).
Properties of the joint PDF: Range of values and “sum” of values,
\(\seteqnumber{1}{3.2}{0}\)\begin{align} 0\le p_{XY}[x_k,y_j] &\le 1 \quad \forall j,k\\ \sum _{j,k} p_{XY}[x_k,y_j] &= 1 \end{align} where the summation runs over every possible index pair \((j,k)\).
-
Example 3.1: Two fair dice are thrown. Neither throw affects the other, so the probability of any particular pair of faces is the product of the two single-die probabilities,
\(\seteqnumber{0}{3.}{2}\)\begin{equation} p_{XY}[x_k,y_j] = \Pr [X=x_k]\cdot \Pr [Y=y_j] = \frac {1}{6}\cdot \frac {1}{6} = \frac {1}{36} \end{equation}
Joint CDF: The joint cumulative distribution function of two discrete random variables is
\(\seteqnumber{0}{3.}{3}\)\begin{equation} \label {eq:rand2:joint_cdf} F_{XY}(x,y) = \Pr (X\le x,\,Y\le y) \end{equation}
Link between the joint PDF and the joint CDF: The joint CDF accumulates the joint PDF, exactly as in the single-variable case (Feature 1.2.1), except that the accumulation now runs over two indices,
\(\seteqnumber{0}{3.}{4}\)\begin{equation} F_{XY}(x,y) = \sum _{\substack {j,k\\ x_k\le x\,\cap \, y_j\le y}} p_{XY}[x_k,y_j] \end{equation}
Expectation of a function of two random variables: For any real-valued function \(g(x,y)\), the two-variable form of Eq. (1.11) is
\(\seteqnumber{0}{3.}{5}\)\begin{equation} \label {eq:rand2:Exy_disc} \E [{g(X,Y)}] = \sum _j\sum _k g(x_k,y_j)\,p_{XY}[x_k,y_j] \end{equation}
3.1.2 Marginal Distributions
Marginal distribution: The marginal distribution of one variable is obtained by summing the joint distribution over all values of the other one,
\(\seteqnumber{1}{3.8}{0}\)\begin{align} p_X[x_k] &=\sum _j p_{XY}[x_k,y_j]\\ p_Y[y_j] &=\sum _k p_{XY}[x_k,y_j]\\ F_X(x) &= F_{XY}(x,\infty )\\ F_Y(y) &= F_{XY}(\infty ,y) \end{align}
-
Example 3.3: An experiment has five equally likely pairs of outcomes,
\[ \begin {array}{ccc} x_k & y_j & p_{XY}[x_k,y_j]\\ \hline 1 & 1 & 1/5\\ 1 & 2 & 1/5\\ 1 & 3 & 1/5\\ 2 & 1 & 1/5\\ 2 & 2 & 1/5 \end {array} \]
Any pair not listed, such as \((2,3)\), has probability zero.
-
(a) Find the marginal probabilities \(p_X[1]\) and \(p_Y[3]\).
-
(b) Evaluate \(F_{XY}(1.5,2.5)\).
-
(c) Compute \(\E [X],\E [X^2],\Var [X],\E [Y],\E [Y^2],\Var [Y]\) and \(\E [XY]\).
-
Solution: Summing a row or a column of the table gives the marginals,
\(\seteqnumber{0}{3.}{8}\)\begin{align*} p_X[1] &= \sum _j p_{XY}[1,y_j]\\ &= p_{XY}[1,1] + p_{XY}[1,2] + p_{XY}[1,3] = \frac {3}{5}\\ p_Y[3] &= \sum _k p_{XY}[x_k,3]\\ &= p_{XY}[1,3] + p_{XY}[2,3] = \frac {1}{5} + 0 = \frac {1}{5} \end{align*} The remaining marginal values follow in the same way, \(p_X[2]=2/5\) and \(p_Y[1]=p_Y[2]=2/5\).
The joint CDF at \((1.5,2.5)\) accumulates the two listed pairs that satisfy both \(x_k\le 1.5\) and \(y_j\le 2.5\), namely \((1,1)\) and \((1,2)\),
\(\seteqnumber{0}{3.}{8}\)\begin{align*} F_{XY}(1.5,2.5) &= p_{XY}[1,1] + p_{XY}[1,2] = \frac {2}{5} \end{align*} The moments of \(X\) and of \(Y\) are computed from their marginals, and the mixed moment from the joint PDF,
\(\seteqnumber{0}{3.}{8}\)\begin{align*} \E [X] &= \sum _k x_k p_X[x_k]\\ &=1\cdot \frac {3}{5} + 2\cdot \frac {2}{5} = \frac {7}{5}\\ \E [X^2] &= \sum _k x_k^2 p_X[x_k]\\ &=1\cdot \frac {3}{5} + 4\cdot \frac {2}{5} = \frac {11}{5}\\ \Var [X] &=\E [X^2] - \bigl (\E [X]\bigr )^2 = \frac {11}{5} - \left (\frac {7}{5}\right )^2 =\frac {6}{25}\\ \E [Y] &= 1\cdot \frac {2}{5} + 2\cdot \frac {2}{5} + 3\cdot \frac {1}{5} = \frac {9}{5}\\ \E [Y^2] &= 1\cdot \frac {2}{5} + 4\cdot \frac {2}{5} + 9\cdot \frac {1}{5} = \frac {19}{5}\\ \Var [Y] &=\E [Y^2] - \bigl (\E [Y]\bigr )^2 = \frac {19}{5} - \left (\frac {9}{5}\right )^2 =\frac {14}{25}\\ \E [XY] &=\sum _j\sum _k x_k y_j\, p_{XY}[x_k,y_j]\\ &=\frac {1}{5}\bigl (1\cdot 1 + 1\cdot 2 + 1\cdot 3 + 2\cdot 1 + 2\cdot 2\bigr )\\ &= \frac {12}{5} \end{align*}
-
3.1.3 Statistical Independence
Independent variables: \(X\) and \(Y\) are statistically independent if and only if the joint distribution factors into the product of the marginals,
\(\seteqnumber{1}{3.9}{0}\)\begin{align} p_{XY}[x_k,y_j] &= p_X[x_k]\,p_Y[y_j]\\ F_{XY}(x,y) &= F_X(x)\,F_Y(y) \end{align}
The marginals were derived from the joint distribution. The natural question is whether the derivation can be run backwards, that is whether
\[ p_{XY}[x_k,y_j]\; \overset {\mathbf {?}}{\longleftarrow }\; p_{X}[x_k],\;p_{Y}[y_j]. \]
Joint and marginal distributions
The two directions are not symmetric:
-
• The marginals always follow from the joint distribution, with no further assumption.
-
• The joint distribution follows from the marginals only when the two variables are statistically independent. Otherwise the marginals are simply not enough: they describe each variable alone and say nothing about how the two move together.
-
Example 3.4: In Example 3.3 the variables are dependent. For instance \(p_{XY}[2,3]=0\), whereas the product of the marginals is \(p_X[2]\,p_Y[3]=\frac {2}{5}\cdot \frac {1}{5}=\frac {2}{25}\ne 0\).
-
Example 3.5: Two independent Bernoulli trials are given, \(X,Y\sim \mathrm {Ber}(p)\). Find the joint PDF \(p_{XY}[x_k,y_j]\) and the joint CDF \(F_{XY}(x,y)\).
-
Solution: Because the trials are independent, the joint PDF is the product of the marginals (Table 3.1),
\(\seteqnumber{1}{3.10}{0}\)\begin{align} p_{XY}[0,0] &= p_X[0]\,p_Y[0] = (1-p)^2,\\ p_{XY}[0,1] &= p_X[0]\,p_Y[1] = (1-p)p,\\ p_{XY}[1,0] &= p_X[1]\,p_Y[0] = p(1-p),\\ p_{XY}[1,1] &= p_X[1]\,p_Y[1] = p^{2}. \end{align} Taking a row sum or a column sum of the table recovers the marginals, each of which is Bernoulli as expected,
\(\seteqnumber{1}{3.11}{0}\)\begin{align} p_X[0] &= p_{XY}[0,0] + p_{XY}[0,1] \nonumber \\ &=(1-p)^2 + (1-p)p = 1-p,\\ p_X[1] &= p_{XY}[1,0] + p_{XY}[1,1] \nonumber \\ &=(1-p)p + p^{2}=p. \end{align} The joint CDF accumulates these four values,
\(\seteqnumber{0}{3.}{11}\)\begin{equation} F_{XY}(x,y)= \begin{cases} 0 & x<0,\;y<0,\\[4pt] p_{XY}[0,0] & 0\le x<1,\;0\le y<1,\\[4pt] p_{XY}[0,0]+p_{XY}[0,1] & 0\le x<1,\;1\le y,\\[4pt] p_{XY}[0,0]+p_{XY}[1,0] & 1\le x,\;0\le y<1,\\[4pt] 1 & 1\le x,\;1\le y, \end {cases} \end{equation}
which is right-continuous in both variables, as a CDF must be.
-
| \(X\) | |||
| \(0\) | \(1\) | ||
| \(Y\) | \(0\) | \((1-p)^{2}\) | \(p(1-p)\) |
| \(1\) | \((1-p)p\) | \(p^{2}\) | |
3.2 Continuous Random Variables
3.2.1 Joint Characterization
Joint CDF: The definition of the joint CDF, Eq. (3.4), is the same for continuous and for discrete variables,
\(\seteqnumber{0}{3.}{12}\)\begin{equation} F_{XY}(x,y) = \Pr (X\le x,\,Y\le y) \end{equation}
Joint PDF: The joint probability density function \(f_{XY}(x,y)\) is the mixed derivative of the joint CDF,
\(\seteqnumber{0}{3.}{13}\)\begin{equation} f_{XY}(x,y)=\frac {\partial ^{2}F_{XY}(x,y)}{\partial x\,\partial y} \end{equation}
Link between the joint PDF and the joint CDF: Integration replaces the summation of the discrete case,
\(\seteqnumber{0}{3.}{14}\)\begin{equation} F_{XY}(x,y)=\int _{-\infty }^{x}\int _{-\infty }^{y}f_{XY}(s,t)\,dt\,ds \end{equation}
Properties of the joint PDF: Range of values and “sum” of values,
\(\seteqnumber{1}{3.16}{0}\)\begin{align} f_{XY}(x,y) &\ge 0 \\ \int _{-\infty }^\infty \int _{-\infty }^\infty f_{XY}(x,y)\,dx\,dy &= 1 =F_{XY}(\infty ,\infty ) \end{align}
-
\[ B=(a,b]\times (c,d] \]
be the rectangle shown in Fig. 3.1. Given the joint CDF \(F_{XY}(x,y)\), find the probability that the pair \((X,Y)\) falls inside \(B\).
-
Solution: Each value of the joint CDF is the probability of an infinite quadrant. The rectangle is assembled from four such quadrants, adding and subtracting them so that every region outside \(B\) is counted as many times as it is removed (Fig. 3.1),
\(\seteqnumber{0}{3.}{16}\)\begin{equation} \label {eq:example:rand2:CDF} \begin{aligned} \Pr ((X,Y)\in B) &=\Pr \bigl (a<X\le b,\;c<Y\le d\bigr )\\ &= F_{XY}(b,d) - F_{XY}(a,d) \\ &\quad - F_{XY}(b,c) + F_{XY}(a,c) \end {aligned} \end{equation}
-
Marginal distribution: The marginal distributions are obtained by integrating the other variable out,
\(\seteqnumber{1}{3.18}{0}\)\begin{align} f_X(x) &= \int _{-\infty }^{\infty }f_{XY}(x,y)\,dy, \\[4pt] f_Y(y) &= \int _{-\infty }^{\infty }f_{XY}(x,y)\,dx, \\[4pt] F_X(x) &= F_{XY}(x,\infty ), \\[4pt] F_Y(y) &= F_{XY}(\infty ,y) \end{align}
Statistical independence: Two continuous random variables \(X\) and \(Y\) are statistically independent if and only if
\(\seteqnumber{1}{3.19}{0}\)\begin{align} f_{XY}(x,y) &= f_X(x)\,f_Y(y), \label {eq:rand2:indep}\\[4pt] F_{XY}(x,y) &= F_X(x)\,F_Y(y) \end{align} Only in this case can the joint distribution be reconstructed from its marginals.
3.2.2 Expectation
Expectation of a function of two random variables: The continuous counterpart of Eq. (3.6) is
\(\seteqnumber{0}{3.}{19}\)\begin{equation} \label {eq:rand2:Exy_cont} \E [{g(X,Y)}] = \iint _{-\infty }^\infty g(x,y)\,f_{XY}(x,y)\,dx\,dy \end{equation}
Linearity of the expectation: The expectation of a sum is the sum of the expectations, for any pair of random variables,
\(\seteqnumber{0}{3.}{21}\)\begin{equation} \label {eq:rand2:linearity} \E [{aX+bY}] = a\E [X] + b\E [Y] \end{equation}
-
Proof. Shown for the representative case \(a=b=1\) and continuous variables. Split the integral into two terms and note that the inner integral of each is exactly the definition of a marginal density,
\(\seteqnumber{0}{3.}{22}\)\begin{align*} \E [{X+Y}] &= \iint _{-\infty }^{\infty } (x+y)\,f_{XY}(x,y)\,dx\,dy \\[6pt] &= \iint _{-\infty }^{\infty } x\,f_{XY}(x,y)\,dx\,dy\\ &\qquad + \iint _{-\infty }^{\infty } y\,f_{XY}(x,y)\,dx\,dy \\[6pt] &= \int _{-\infty }^{\infty } x\,f_X(x)\,dx + \int _{-\infty }^{\infty } y\,f_Y(y)\,dy \\[6pt] &= \E [X] + \E [Y] \end{align*} The same argument with sums in place of integrals proves the discrete case.
Expectation of a product of independent variables: For two independent random variables and a separable function \(g(x,y)=g_1(x)\,g_2(y)\), the expectation factors,
\(\seteqnumber{0}{3.}{22}\)\begin{equation} \label {eq:rand2:Eg1g2} \E [{g_1(X)g_2(Y)}] = \E [{g_1(X)}]\,\E [{g_2(Y)}] \end{equation}
The special case used throughout this chapter, valid for independent variables only, is
\(\seteqnumber{0}{3.}{23}\)\begin{equation} \label {eq:rand2:ExyExEy} \E [XY] = \E [X]\,\E [Y] \end{equation}
-
Proof. Independence, Eq. (3.19a), lets the joint density be replaced by the product \(f_X(x)f_Y(y)\), after which the double integral separates,
\(\seteqnumber{0}{3.}{24}\)\begin{equation} \begin{aligned} \E [XY] &= \iint _{-\infty }^{\infty } x\,y\,f_X(x)\,f_Y(y)\,dx\,dy \\[6pt] &= \left (\int _{-\infty }^{\infty } x\,f_{X}(x)\,dx\right ) \left (\int _{-\infty }^{\infty } y\,f_{Y}(y)\,dy\right ) \end {aligned} \end{equation}
which is Eq. (3.24). The discrete case follows in the same way.
Independence is required
3.2.3 Bi-variate Uniform Distribution
Bi-variate uniform distribution: The joint PDF of an axis-aligned two-dimensional uniform law over the rectangle \([a,b]\times [c,d]\) is
\(\seteqnumber{0}{3.}{25}\)\begin{equation} f_{XY}(x,y)= \begin{cases} \dfrac {1}{b-a}\,\dfrac {1}{d-c}, & a \le x \le b,\; c \le y \le d,\\[6pt] 0, & \text {otherwise} \end {cases} \end{equation}
-
Example 3.9: For the bi-variate uniform distribution:
-
(a) Compute \(\E [X]\) from the general expectation formula, Eq. (3.20).
-
(b) Show that \(X\sim \mathrm {U}[a,b]\) and \(Y\sim \mathrm {U}[c,d]\) are independent.
-
Solution: Take \(g(x,y)=x\) in Eq. (3.20). The integral over \(y\) contributes a factor of one,
\[ \begin {aligned} \E [X] &= \iint _{-\infty }^{\infty } x\,f_{XY}(x,y)\,dx\,dy\\ &= \int _{a}^{b}\frac {x}{b-a}\,dx \int _{c}^{d}\frac {dy}{d-c} = \frac {a+b}{2} \end {aligned} \]
which is the same result as for a single uniform variable.
For the second part, integrate the joint density over \(y\),
\[ f_X(x)=\int _{-\infty }^{\infty } f_{XY}(x,y)\,dy = \begin {cases} \dfrac {1}{b-a}, & a\le x \le b,\\[6pt] 0, & \text {otherwise} \end {cases} \]
and a symmetric computation gives \(f_Y(y)\). Since \(f_{XY}(x,y)=f_X(x)f_Y(y)\), condition (3.19a) holds and the two variables are independent. Consequently, by Eq. (3.24),
\[ \E [XY] = \E [X]\,\E [Y] = \frac {a+b}{2}\cdot \frac {c+d}{2} \]
-
-
Example 3.10: For the special case \(a=c=0\), \(b=d=1\), find the joint CDF.
-
Solution: The joint density equals one on the unit square, so the CDF is the area of the part of the square that lies below and to the left of \((x,y)\),
\(\seteqnumber{0}{3.}{26}\)\begin{equation} F_{XY}(x,y)= \begin{cases} 0 & x<0 \text { or } y<0,\\[4pt] xy & 0\le x \le 1,\; 0\le y \le 1,\\[4pt] x & 0\le x \le 1,\; 1<y,\\[4pt] y & 1< x,\; 0\le y \le 1,\\[4pt] 1 & 1<x,\; 1<y \end {cases} \end{equation}
-
3.3 Covariance
3.3.1 Definition
-
Example 3.11: Expand \(\Var [{X+Y}]\) in terms of the variances of \(X\) and of \(Y\).
-
Solution: Start from the definition of the variance and center each variable separately,
\(\seteqnumber{0}{3.}{27}\)\begin{equation} \begin{aligned} \Var [{X+Y}] &= \E [{\bigl (X+Y-\E [{X+Y}]\bigr )^2}]\\ &= \E [{\bigl (\left (X-\E [X]\right ) + \left (Y-\E [Y]\right )\bigr )^2}]\\ &= \E [{\bigl (X-\E [X]\bigr )^2}] + \E [{\bigl (Y-\E [Y]\bigr )^2}]\\ &\qquad + 2\,\E [{\bigl (X-\E [X]\bigr )\bigl (Y-\E [Y]\bigr )}] \end {aligned} \end{equation}
The first two terms are \(\Var [X]\) and \(\Var [Y]\). The third term does not belong to either variable alone: it is the covariance, defined next.
-
Covariance: The covariance of two random variables \(X\) and \(Y\) is
\(\seteqnumber{0}{3.}{28}\)\begin{equation} \label {eq:rand2:cov_def} \Cov [X,Y] = \E [{\bigl (X-\E [X]\bigr )\bigl (Y-\E [Y]\bigr )}] \end{equation}
Covariance, alternative definition: The form used in practice, because it needs only the three moments \(\E [XY]\), \(\E [X]\) and \(\E [Y]\), is
\(\seteqnumber{0}{3.}{29}\)\begin{equation} \Cov [X,Y] = \E [XY]-\E [X]\,\E [Y] \end{equation}
-
Proof. Expand the product in Eq. (3.29) and use the linearity of the expectation together with the fact that \(\E [X]\) and \(\E [Y]\) are constants,
\(\seteqnumber{0}{3.}{30}\)\begin{equation} \label {eq:rand2:cov_proof} \begin{aligned} \Cov [X,Y] &= \E [{\bigl (X-\E [X]\bigr )\bigl (Y-\E [Y]\bigr )}]\\ &=\E [XY] - \E [{X\E [Y]}] - \E [{Y\E [X]}] + \E [X]\E [Y]\\ &=\E [XY] - 2\E [X]\E [Y] + \E [X]\E [Y]\\ &=\E [XY]-\E [X]\E [Y] \end {aligned} \end{equation}
Covariance and variance
Properties of the covariance: The covariance is symmetric, it is blind to a shift of either variable, and it scales with both,
\(\seteqnumber{1}{3.32}{0}\)\begin{align} \Cov [X,X] & = \Var [X] \label {eq:rand2:covxx} \\[4pt] \Cov [X,Y] & = \Cov [Y,X] \label {eq:rand2:covxy}\\[4pt] \Cov [X,a] & = 0 \\[4pt] \Cov [aX,bY] & = ab\,\Cov [X,Y] \\[4pt] \Cov [{X+a,\,Y+b}] & = \Cov [X,Y] \\[4pt] \Var [{X\pm Y}] & = \Var [X]+\Var [Y] \pm 2\,\Cov [X,Y] \label {eq:rand2:sum_cov} \end{align}
The variance is not linear
Eq. (3.32f) is the reason the variance, unlike the expectation, cannot simply be moved through a sum. The cross term disappears only when the covariance is zero.
Covariance of independent variables: Two statistically independent random variables always satisfy
\(\seteqnumber{0}{3.}{32}\)\begin{equation} \Cov [X,Y]=0 \end{equation}
Variance of a sum of independent variables: For independent variables only, the cross term of Eq. (3.32f) vanishes and the variance becomes additive,
\(\seteqnumber{0}{3.}{33}\)\begin{equation} \label {eq:rand2:independence_var} \Var [{aX+bY}] = a^{2}\Var [X] + b^{2}\Var [Y] \end{equation}
Cauchy-Schwarz inequality: The mixed moment and the covariance are both bounded by the corresponding second moments,
\(\seteqnumber{1}{3.35}{0}\)\begin{align} \bigl (\E [XY]\bigr )^2 &\le \E [X^{2}]\,\E [Y^{2}],\\[6pt] \bigl (\Cov [X,Y]\bigr )^2 &\le \Var [X]\,\Var [Y]\label {eq:rand2:cauchy} \end{align}
-
Proof. Start from the fact that the expectation of a square is never negative,
\[ \E [{(aX+Y)^{2}}]=a^{2}\E [X^{2}]+2a\,\E [XY]+\E [Y^{2}] \ge 0, \]
for every real \(a\). A non-negative quadratic in \(a\) has a non-positive discriminant,
\[ 4\bigl (\E [XY]\bigr )^2 - 4\,\E [X^{2}]\,\E [Y^{2}] \le 0, \]
which is the first inequality. Replacing \(X\to X-\E [X]\) and \(Y\to Y-\E [Y]\) turns the second moments into variances and the mixed moment into the covariance, giving the second inequality.
3.3.2 Correlation Coefficient
Correlation coefficient: The correlation coefficient, also called the Pearson product-moment correlation coefficient, is the covariance normalized by the two standard deviations,
\(\seteqnumber{0}{3.}{35}\)\begin{equation} \label {eq:rand2:rho} \rho _{XY}=\frac {\Cov [X,Y]}{\sqrt {\Var [X]\,\Var [Y]}} \end{equation}
Range of the correlation coefficient: The correlation coefficient is bounded,
\(\seteqnumber{0}{3.}{36}\)\begin{equation} \abs {\rho _{XY}}\le 1 \end{equation}
which follows directly from dividing the Cauchy-Schwarz inequality (3.35b) by \(\Var [X]\Var [Y]\).
Perfect linear dependence: The bound is attained, \(\rho _{XY}=\pm 1\), if and only if \(Y\) is an exact linear function of \(X\). The sign of \(\rho _{XY}\) is the sign of the slope.
Uncorrelated variables: Two random variables are uncorrelated, meaning that they exhibit no linear relation, when
\(\seteqnumber{0}{3.}{37}\)\begin{equation} \label {eq:rand2:uncorrelated} \Cov [X,Y]=\rho _{XY}=0 \end{equation}
Orthogonal variables: Two random variables are orthogonal when their mixed moment vanishes,
\(\seteqnumber{0}{3.}{38}\)\begin{equation} \E [XY] = 0 \end{equation}
For variables with zero mean, orthogonality and uncorrelatedness coincide.
Uncorrelated is weaker than independent
-
Example 3.12: Compute the correlation coefficient \(\rho _{XY}\) for the discrete pair of Example 3.3.
-
Solution: The moments were already computed there, so only the covariance is left,
\[ \Cov [X,Y] = \E [XY]-\E [X]\,\E [Y] = \frac {12}{5}-\frac {7}{5}\cdot \frac {9}{5} = -\frac {3}{25} \]
and therefore
\[ \rho _{XY} = \frac {-3/25}{\sqrt {\frac {6}{25}\cdot \frac {14}{25}}} = -\frac {3}{\sqrt {84}} = -\frac {\sqrt {21}}{14} \approx -0.327 \]
The two variables are weakly and negatively related.
-
-
Compute \(\Var [X]\), \(\Var [Y]\), \(\Var [{X+Y}]\), \(\Cov [X,Y]\) and \(\rho _{XY}\) for
\[ X\sim \mathrm {U}[0,1], \qquad Y = -X \]
-
\(\seteqnumber{0}{3.}{39}\)
\begin{align*} \Var [X] &= \frac {(b-a)^2}{12} = \frac {1}{12}\\[2pt] \Var [Y] &= \Var [{(-1)X}] = (-1)^2\Var [X] = \Var [X]\\ \Var [{X+Y}] &= \Var [{X-X}] = 0\\ \Cov [X,Y] &=\Cov [{X,-X}]\\ &= \E [{X(-X)}] - \E [X]\,\E [{-X}] \\ &= -\bigl (\E [X^2] - \bigl (\E [X]\bigr )^2\bigr ) \\ &=-\Var [X]\\ \rho _{XY} &= \frac {-\Var [X]}{\sqrt {\Var [X]\Var [X]}} = -1 \end{align*} The correlation coefficient reaches its lower bound, as it must for an exact linear relation with a negative slope.
-
\(\seteqnumber{0}{3.}{39}\)
-
Compute \(\Cov [X,Y]\) and \(\rho _{XY}\) for
\[ X \sim \mathrm {U}[-1,1], \qquad Y = X^{2} \]
-
Solution: The density of \(X\) is symmetric about zero, so every odd moment vanishes,
\(\seteqnumber{0}{3.}{39}\)\begin{align*} \E [X] &= \frac {1 + (-1)}{2} = 0\\ \E [XY] &= \E [X^{3}] = \int _{-1}^{1}x^{3}\,\frac {dx}{2} = 0\\ \Cov [X,Y] &= \E [XY] - \cancelto {0}{\E [X]}\, \E [Y] = 0\\ \rho _{XY} &= 0 \end{align*} Knowing \(X\) determines \(Y\) exactly, so the two are as dependent as they could possibly be, and yet the correlation coefficient reports nothing. The relation is purely non-linear, and Eq. (3.36) measures only the linear part.
-
3.4 Bivariate Gaussian Distribution
Sum of independent Gaussian variables: A weighted sum of independent Gaussian variables is again Gaussian. For \(X \sim N(\mu _x,\sigma _x^2)\) and \(Y\sim N(\mu _y,\sigma _y^2)\) independent,
\(\seteqnumber{0}{3.}{39}\)\begin{equation} \label {eq:rand2:gauss_sum} aX+bY \sim N\bigl (a\mu _x + b\mu _y,\;a^2\sigma _x^2 + b^2\sigma _y^2\bigr ) \end{equation}
The mean follows from Eq. (3.22) and the variance from Eq. (3.34). What is new is that the shape of the distribution is preserved.
Jointly Gaussian variables: Random variables \(X_1,X_2,\ldots ,X_N\), dependent or not, are jointly Gaussian if and only if every linear combination
\[ \sum _{m=1}^N a_m X_m, \qquad a_m\in \mathbb {R}, \]
is a Gaussian random variable.
Bivariate Gaussian PDF: A jointly Gaussian pair is fully described by five numbers: the two means, the two variances, and the correlation coefficient. Its joint PDF is
\(\seteqnumber{0}{3.}{40}\)\begin{multline} \label {eq:rand2:gauss_pdf} f_{X_1X_2}(x_1,x_2) = \frac {1}{2 \pi \sigma _1 \sigma _2 \sqrt {1-\rho ^2}} \exp \left ( -\frac {1}{2(1-\rho ^2)}\times \right . \\ \left . \times \left [ \frac {(x_1-\mu _1)^2}{\sigma _1^2} + \frac {(x_2-\mu _2)^2}{\sigma _2^2} - \frac {2\rho (x_1-\mu _1)(x_2-\mu _2)}{\sigma _1 \sigma _2} \right ] \right ) \end{multline} where \(\mu _i=\E [X_i]\), \(\sigma _i^2=\Var [X_i]\) and \(\rho =\rho _{X_1X_2}\). The construction that produces this density is given in the appendix to this chapter.
Marginal distributions: The marginal distributions of a jointly Gaussian pair are Gaussian, \(X_i\sim N(\mu _i,\sigma _i^2)\).
Marginally Gaussian is not jointly Gaussian
The converse of the feature above is false. Two variables can each be Gaussian on their own and still fail to be jointly Gaussian, as the counterexample below shows. Definition 3.4 is a statement about every linear combination, not about the two marginals.
Jointly Gaussian uncorrelated variables: For a jointly Gaussian pair, and only for such a pair, uncorrelatedness and independence are the same thing,
\(\seteqnumber{0}{3.}{41}\)\begin{equation} \rho _{XY}=0 \iff X,Y \text { independent} \end{equation}
Setting \(\rho =0\) in Eq. (3.41) indeed factors the joint density into the product of the two marginals.
-
Example 3.15: Two variables are given, \(X\sim N(0,\sigma ^2)\) and \(Y=3X\).
-
(a) State the correlation coefficient without computing it.
-
(b) Show that \(X\) and \(Y\) are jointly Gaussian.
-
(c) Compute \(\Var [Y]\) and \(\Cov [X,Y]\), and give the joint distribution.
-
-
(a) \(Y\) is an exact linear function of \(X\) with a positive slope, so \(\rho _{XY}=1\).
-
(b) Any linear combination collapses to a multiple of \(X\),
\[ a_1 X + a_2 Y = a_1 X + 3a_2 X = (a_1 + 3a_2)\,X \sim N\left (0,(a_1+3a_2)^2\sigma ^2\right ), \]
which is Gaussian for every \(a_1,a_2\). By Definition 3.4 the pair is jointly Gaussian.
-
(c) Both variables have zero mean, so
\(\seteqnumber{0}{3.}{42}\)\begin{align*} \Var [Y] &= 3^2\,\E [X^2] = 9\sigma ^2,\\ \Cov [X,Y] &= \E [{3X^2}] = 3\sigma ^2, \end{align*} and \(\rho _{XY}=3\sigma ^2/\sqrt {\sigma ^2\cdot 9\sigma ^2}=1\), confirming part (a). The joint distribution is the bivariate Gaussian of Eq. (3.41) with \(\mu _1=\mu _2=0\), \(\sigma _1=\sigma \), \(\sigma _2=3\sigma \) and \(\rho =1\).
-
-
-
Let \(X\sim N(0,1)\) and let \(W\) be an independent sign, \(\Pr [W=1]=\Pr [W=-1]=\tfrac 12\). Define \(Y = W X\).
-
Solution: Conditioned on either value of \(W\) the variable \(Y\) is standard Gaussian, so its marginal distribution is \(N(0,1)\). The pair is uncorrelated,
\(\seteqnumber{0}{3.}{42}\)\begin{align*} \Cov [X,Y] &= \E [XY] - \E [X]\,\E [Y] = \E [{X^2W}]\\ &= \E [X^2]\,\E [W] = \E [X^2]\cdot 0 = 0 \end{align*} but it is clearly dependent, since \(\abs {X}=\abs {Y}\) always. Were the pair jointly Gaussian, Feature 3.4 would force independence, so it is not. A more direct argument is that \(\Pr (X+Y=0)=\tfrac 12\), whereas any continuous joint density assigns probability zero to a line.
-
-
Example 3.17: Let \(X,Y\) have \(\Cov [X,Y]\ne 0\), and define \(Z = aX + Y\) with a deterministic constant \(a\).
-
(a) Can \(a\) be chosen so that \(X\) and \(Z\) are uncorrelated?
-
(b) Repeat, assuming in addition that \(X,Y\) are jointly Gaussian.
-
Solution: Expand the covariance of \(X\) with \(Z\),
\(\seteqnumber{0}{3.}{42}\)\begin{align*} \E [Z] &= a\E [X] + \E [Y]\\ \E [XZ] &= a\E [X^2] + \E [XY]\\ \Cov [X,Z] &= a\E [X^2] + \E [XY] - a\bigl (\E [X]\bigr )^2 - \E [X]\E [Y]\\ &= a\Var [X] + \Cov [X,Y] \end{align*} so the choice
\[ a = -\frac {\Cov [X,Y]}{\Var [X]} \]
makes them uncorrelated. If in addition \(X,Y\) are jointly Gaussian, then \(Z\) is a linear combination of them and the pair \((X,Z)\) is jointly Gaussian too. In that case Feature 3.4 upgrades the conclusion: \(X\) and \(Z\) are not merely uncorrelated but fully independent.
-
3.5 Exercises
3.1 (Covariance) The following relations hold for the random variables \(X,Y\),
\(\seteqnumber{0}{3.}{42}\)\begin{align*} \Var [{X+2Y}] &= 40\\ \Var [{X-2Y}] &= 20\\ \Var [X] &= \Var [Y] \end{align*} Compute \(\Var [X]\) and \(\Cov [X,Y]\) numerically.
3.2 (Correlation coefficient of discrete variables) The joint distribution of the discrete random variables \(X,Y\) is
\[ p_{XY}[x,y] = \begin {cases} \Pr [X=0,Y=-1] = \tfrac 13,\\[3pt] \Pr [X=-1,Y=0] = \tfrac 13,\\[3pt] \Pr [X=1,Y=1] = \tfrac 16,\\[3pt] \Pr [X=-1,Y=-1] = \tfrac 16 \end {cases} \]
Compute the correlation coefficient \(\rho _{XY}\).
3.3 (Product and sum of uniform variables) Let \(n\) independent random variables \(X_i\sim \mathrm {U}[0,1]\), \(i = 1,\ldots ,n\), be given, and define
\(\seteqnumber{0}{3.}{42}\)\begin{align*} Y &= X_1\cdot X_2\cdot \ldots \cdot X_n,\\ Z &= X_1 + X_2 + \ldots + X_n \end{align*} Compute \(\E [Y],\;\Var [Y],\;\E [Z],\;\Var [Z]\).
3.4 (Correlation coefficient) Given the joint PDF
\[ f_{XY}(x,y) = \exp \!\bigl (-\tfrac {4x+y}{2}\bigr )\,u(x)\,u(y), \]
where \(u(\cdot )\) is the unit step function, find the correlation coefficient \(\rho _{XY}\).
3.5 (Linearly related variables) Given the relation
\[ Y = -6X + 22, \]
with \(\E [X] = 3\) and \(\Var [X] = 2\):
-
(a) Compute \(\E [Y]\) and \(\Var [Y]\).
-
(b) Compute \(\Cov [X,Y]\) and \(\rho _{XY}\), and explain the result.
3.6 (Noisy radius measurements) Radii of circles are measured. The true radii are distributed as \(r \sim \mathrm {U}[a=1,b=3]\) and the measurement error is \(n \sim N(\mu =0,\sigma ^2=0.01)\). The true radius and the error are independent, and the observed measurement is \(X = r + n\). The circumference and the area of the observed circle are
\[ C = 2\pi X, \qquad A = \pi X^2 \]
Compute:
-
(a) The expected circumference \(\E [C]\).
-
(b) The variance of the circumference \(\Var [C]\).
-
(c) The expected area \(\E [A]\).
-
(d) The covariance \(\Cov [{X,r}]\).
3.7 (Uncorrelated but dependent) Define \(\Theta \sim \mathrm {U}[-\pi ,\pi ]\) and
\[ X = \cos (\Theta ),\qquad Y = \sin (\Theta ) \]
-
(a) Prove that \(X\) and \(Y\) are uncorrelated.
-
(b) Compute \(\E [X^2]\) and \(\E [Y^2]\).
-
(c) Show by a counterexample that \(X\) and \(Y\) are not independent. Hint: for independent variables Eq. (3.23) must hold for every pair of functions \(g_1,g_2\).
3.8 (Variance of a difference) Let \(X,Y\) be arbitrary random variables.
-
(a) Derive an expression for \(\Var [{X - Y}]\).
-
(b) Now assume that \(X\sim N(\mu _1,\sigma _1^2)\) and \(Y\sim N(\mu _2,\sigma _2^2)\) are jointly Gaussian with correlation coefficient \(\rho \). Express \(\E [{X - Y}]\) and \(\Var [{X - Y}]\) in terms of the distribution parameters.
3.9 (CDF of a Gaussian pair) Two jointly Gaussian random variables are given, \(X\sim N\bigl (\tfrac 12,1\bigr )\) and \(Y\sim N\bigl (\tfrac 12,2^2\bigr )\), with correlation coefficient \(\rho =\tfrac 12\). Denote their CDFs by \(F_X(x),F_Y(y),F_{XY}(x,y)\) and express the probabilities
\[ \Pr (-1<X<1,\;Y<1), \quad \Pr (X<1,\;-1<Y) \]
in terms of them. Hint: use Example 3.7.
3.10 (Rotating a Gaussian pair) Let
\[ X_1\sim N(m,\sigma ^2),\quad X_2\sim N(m,\sigma ^2) \]
be jointly Gaussian. Do not assume that they are independent. Define the rotated pair
\(\seteqnumber{0}{3.}{42}\)\begin{align*} V &= X_1\cos (\theta ) + X_2\sin (\theta ),\\ W &= -\,X_1\sin (\theta ) + X_2\cos (\theta ) \end{align*}
-
(a) Find every \(\theta \in [-\pi ,\pi ]\) for which \(V\) and \(W\) are independent.
-
(b) Give the joint distribution of \((V,W)\) and its parameters. Here you may write \(\E [{X_1X_2}]=b\), and you may not assume the special value of \(\theta \) found in part (a).
3.11 (Sum of Bernoulli variables) Three independent Bernoulli variables are given, \(X_1\sim \mathrm {Ber}(p_1)\), \(X_2\sim \mathrm {Ber}(p_2)\), \(X_3\sim \mathrm {Ber}(p_3)\).
-
(a) Compute the probabilities \(\Pr (X_1+X_2+X_3 = 1)\) and \(\Pr (X_1+X_2+X_3 = 2)\).
-
(b) Verify the result by simulation, using values \(p_i\ne 0.5\).
3.12 (Simulation) Two independent random variables \(X,Y\sim \mathrm {U}[0,1]\) are given. Show by simulation that
\(\seteqnumber{0}{3.}{42}\)\begin{equation*} \Pr \left (X^{\frac {1}{3}}>\frac {Y}{2}\right )=\frac {31}{32} = 0.96875 \end{equation*}
3.13 (Simulation of a discrete pair) Simulate the sum of two fair dice and plot the empirical distribution of the sum. Compare the result to the exact distribution obtained by counting the \(36\) equally likely pairs.
Appendices
3.A Constructing a Bivariate Gaussian Pair
Eq. (3.41) was stated without derivation. The construction below shows where its five parameters come from: every jointly Gaussian pair is a linear mixture of two independent standard Gaussian variables.
Let \(W_1,W_2\sim N(0,1)\) be independent, and build
\(\seteqnumber{1}{3.43}{0}\)\begin{align} X_1 &= \mu _1 + \sigma _{11}W_1 + \sigma _{12}W_2\\ X_2 &= \mu _2 + \sigma _{21}W_1 + \sigma _{22}W_2 \end{align} Each of \(X_1,X_2\) is a weighted sum of independent Gaussian variables, hence Gaussian by Eq. (3.40). The same holds for any linear combination \(a_1X_1+a_2X_2\), since it too reduces to a weighted sum of \(W_1\) and \(W_2\). By Definition 3.4 the pair is therefore jointly Gaussian.
The means follow from the linearity of the expectation and \(\E [W_i]=0\),
\(\seteqnumber{1}{3.44}{0}\)\begin{align} \E [X_1] &= \mu _1 + \sigma _{11}\E [W_1] + \sigma _{12}\E [W_2] = \mu _1\\ \E [X_2] &= \mu _2 \end{align} The variances follow from Eq. (3.34) and \(\Var [W_i]=1\),
\(\seteqnumber{1}{3.45}{0}\)\begin{align} \Var [X_1] &= \sigma _{11}^2\Var [W_1]+\sigma _{12}^2\Var [W_2] = \sigma _{11}^2+\sigma _{12}^2 \equiv \sigma _1^2\\ \Var [X_2] &= \sigma _{21}^2+\sigma _{22}^2 \equiv \sigma _2^2 \end{align} For the covariance, expand the product. The cross terms in \(W_1W_2\) drop out because the two are independent with zero mean, and the terms \(\E [W_i^2]=1\) survive,
\(\seteqnumber{1}{3.46}{0}\)\begin{align} \E [{X_1X_2}] &=\mu _1\mu _2 + \sigma _{11}\sigma _{21}\E [W_1^2] + \sigma _{12}\sigma _{22}\E [W_2^2]\nonumber \\ &=\mu _1\mu _2 + \sigma _{11}\sigma _{21} + \sigma _{12}\sigma _{22}\\ \Cov [X_1,X_2] &= \E [{X_1X_2}] - \E [X_1]\E [X_2]\nonumber \\ &= \sigma _{11}\sigma _{21} + \sigma _{12}\sigma _{22} \end{align} and the correlation coefficient is
\(\seteqnumber{0}{3.}{46}\)\begin{equation} \rho = \frac {\Cov [X_1,X_2]}{\sqrt {\Var [X_1]\Var [X_2]}} = \frac {\sigma _{11}\sigma _{21} + \sigma _{12}\sigma _{22}}{\sigma _1\sigma _2} \end{equation}
Four mixing weights \(\sigma _{11},\sigma _{12},\sigma _{21},\sigma _{22}\) produce only three distinct quantities, \(\sigma _1^2\), \(\sigma _2^2\) and \(\rho \). Together with the two means \(\mu _1,\mu _2\), these are exactly the five parameters appearing in Eq. (3.41). Changing the weights while keeping the three derived quantities fixed amounts to rotating \((W_1,W_2)\), which leaves the joint density unchanged.