{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"remove_cell"
]
},
"outputs": [],
"source": [
"# HIDDEN\n",
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"from datascience import *\n",
"from prob140 import *\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"plt.style.use('fivethirtyeight')\n",
"%matplotlib inline\n",
"from scipy import stats"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Random Vectors ##"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Vectors and matrices give us a compact way of referring to random sequences like $X_1, X_2, \\ldots, X_n$. The algebra of vectors and matrices gives us powerful tools for studying linear combinations of random variables.\n",
"\n",
"In this section we will develop matrix notation for random sequences and then express familiar consequences of linearity of expectation and bilinearity of covariance in matrix notation. The probability theory in this section is not new – it consists of expectation and covariance facts that you have known for some time. But the representation is new and leads us to new insights."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A *vector valued random variable*, or more simply, a *random vector*, is a list of random variables defined on the same space. We will think of it as an $n \\times 1$ column vector.\n",
"\n",
"$$\n",
"\\mathbf{X} ~ = ~ \n",
"\\begin{bmatrix}\n",
"X_1 \\\\\n",
"X_2 \\\\\n",
"\\vdots \\\\\n",
"X_n\n",
"\\end{bmatrix}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For ease of display, we will sometimes write $\\mathbf{X} = [X_1 X_2 \\ldots X_n]^T$ where $\\mathbf{M}^T$ is notation for the transpose of the matrix $\\mathbf{M}$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The *mean vector* of $\\mathbf{X}$ is $\\boldsymbol{\\mu} = [\\mu_1 ~ \\mu_2 ~ \\ldots ~ \\mu_n]^T$ where $\\mu_i = E(X_i)$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The *covariance matrix* of $\\mathbf{X}$ is the $n \\times n$ matrix $\\boldsymbol{\\Sigma}$ whose $(i, j)$ element is $Cov(X_i, X_j)$. \n",
"\n",
"The $i$th diagonal element of $\\boldsymbol{\\Sigma}$ is the variance of $X_i$. The matrix is symmetric because of the symmetry of covariance."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Quick Check\n",
"A random vector $\\begin{bmatrix} X \\\\ Y \\end{bmatrix}$ has mean vector $\\begin{bmatrix} 0 \\\\ 0 \\end{bmatrix}$ and covariance matrix $\\begin{bmatrix} 1 & 2.4 \\\\ ? & 9\\end{bmatrix}$.\n",
"\n",
"Which (if any) of $X$ and $Y$ are in standard units? Pick one option.\n",
"\n",
"(i) Only $X$\n",
"\n",
"(ii) Only $Y$\n",
"\n",
"(iii) Both $X$ and $Y$\n",
"\n",
"(iv) Neither $X$ nor $Y$\n",
"\n",
"(v) There is not enough information to answer.\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Answer\n",
":class: dropdown\n",
"(i)\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Quick Check\n",
"(Continuing the Quick Check above) Fill in the ? in the covariance matrix.\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Answer\n",
":class: dropdown\n",
"$2.4$\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Quick Check\n",
"(Continuing the Quick Check above) Find the correlation between $X$ and $Y$.\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Answer\n",
":class: dropdown\n",
"$0.8$\n",
"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"remove-input",
"hide-output"
]
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"