{
"cells": [
{
"cell_type": "markdown",
"id": "1dad883c-f842-48ca-81ef-4ab2d600dc54",
"metadata": {},
"source": [
"# Multivariate discrete distributions\n",
"\n",
"Multivariate discrete pmfs are the extension of univariate discrete distributions over multiple variables.\n",
"The definition of independence can be extended from events to discrete random variables.\n",
"We discuss results concerning the expectation and independence of discrete random variables."
]
},
{
"cell_type": "markdown",
"id": "a76fc83d-4f26-4bbf-81d0-3bfb4f4fbb89",
"metadata": {},
"source": [
"## Definition\n",
"\n",
"The definition of the pmf of a discrete random variable can be extended into a distribution over several random variables in the following way.\n",
"\n",
":::{prf:definition} Joint probability mass function\n",
"\n",
"Given random variables $X$ and $Y$ on $(\\Omega, \\mathcal{F}, \\mathbb{P})$, the joint probability mass function over $X$ and $Y$ is the function $p_{X, Y} : \\mathbb{R}^2 \\to [0, 1]$ defined by\n",
" \n",
"$$\\begin{align}\n",
"p_{X, Y}(x, y) = \\mathbb{P}\\left(\\{\\omega \\in \\Omega : X(\\omega) = x, Y\n",
"(\\omega) = y\\}\\right).\n",
"\\end{align}$$\n",
"\n",
"This is usually abbreviated to $p_{X, Y}(x, y) = \\mathbb{P}\\left(X = x, Y = y\\right)$.\n",
":::\n",
"\n",
"Using the additivity of $\\mathbb{P}$, we can verify that $p_{X, Y}$ also satisfies the marginalisation property\n",
"\n",
"$$\\begin{align} p_X(x) = \\sum_{y \\in \\text{Im}Y} \\mathbb{P}\\left(X = x, Y = y\n",
"\\right),\n",
"\\end{align}$$\n",
"\n",
"and also since $\\mathbb{P}(\\Omega) = 1$ we have\n",
"\n",
"$$\\begin{align}\n",
"\\sum_{x \\in \\text{Im}X} \\sum_{y \\in \\text{Im}Y} p_{X, Y}(x, y) = 1.\n",
"\\end{align}$$\n",
"\n",
"This definition can be extended to multivariate distributions of more than two variables by adding more variables to the set being measured."
]
},
{
"cell_type": "markdown",
"id": "b5e829df-c63d-4a97-8c70-840c4f4ed16d",
"metadata": {},
"source": [
"## Expectation and independence\n",
" \n",
"We are often interested in taking the expectation of functions of multiple random variables, given by the following formula which is the extension of its univariate version.\n",
" \n",
":::{prf:theorem} Law of the subconscious statistician - multivariate\n",
"\n",
"Let $X$ and $Y$ be discrete random variables on $(\\Omega, \\mathcal{F}, \\mathbb{P})$ and $g : \\mathbb{R}^2 \\to \\mathbb{R}$. Then\n",
" \n",
"$$\\begin{align}\n",
"\\mathbb{E}(g(X, Y)) = \\sum_{x \\in \\text{Im} X}\\sum_{y \\in \\text{Im} Y} g(x, y) \\mathbb{P}(X = x, Y = y)\n",
"\\end{align}$$\n",
" \n",
"whenever this sum converges absolutely.\n",
":::\n",
"\n",
"\n",
"Often, downstream calculations, including the expectation written above, can be simplified if the random variables are independent. Previously we defined independence in terms of events and we can extend this concept to variables in the following intuitive way.\n",
"\n",
":::{prf:definition} Independence\n",
"\n",
"Two discrete random variables $X$ and $Y$ are independent if ${X = x}$ and ${Y = y}$ are independent for all $x, y \\in \\mathbb{R}$, and we typically abbreviate this condition as\n",
" \n",
"$$\\begin{align}\n",
"\\mathbb{P}(X = x, Y = y) = \\mathbb{P}(X = x)\\mathbb{P}(Y = y) \\text{ for } x, y \\in \\mathbb{R}.\n",
"\\end{align}$$\n",
" \n",
"Random variables which are not independent are called dependent.\n",
"\n",
":::\n",
"\n",
"Two discrete random variables are independent if their pmf can be expressed as the product of its marginals, or more generally as the product of functions of different arguments, as shown below.\n",
" \n",
"\n",
":::{prf:theorem} Independence $\\iff$ pmf factorises\n",
"\n",
"Two discrete random variables $X$ and $Y$ are independent if and only if there exist $f, g: \\mathbb{R} \\to \\mathbb{R}$ such that\n",
" \n",
"$$\\begin{align}\n",
"p_{X, Y}(x, y) = f(x)g(y) \\text{ for } x, y \\in \\mathbb{R}.\n",
"\\end{align}$$\n",
":::\n",
"\n",
"This can be proved by showing that the product $f(x)g(y)$ is equal to $p_X(x)p_Y(y)$. A related result is that if two random variables are independent, the expectation of their product is equal to the product of their expectations.\n",
"\n",
":::{prf:theorem} Expectation of product of independent variables\n",
"\n",
"If $X$ and $Y$ are independent discrete random variables, the expectation of their product is equal to the product of their expectations, as in\n",
" \n",
"$$\\begin{align}\n",
"\\mathbb{E}(XY) = \\mathbb{E}(X)\\mathbb{E}(Y).\n",
"\\end{align}$$\n",
"\n",
":::\n",
"\n",
"This can be proved by considering the expectation of $XY$, factoring $p_{X, Y}$ into $p_X p_Y$ and rearranging the expectation in terms of expectations over $X$ and $Y$. We also have the following useful result relating factorisation and independence.\n",
"\n",
":::{prf:theorem} Independence $\\iff$ expected product of functions factorises\n",
"\n",
"Discrete random variables $X$ and $Y$ are independent if and only if\n",
"\n",
"$$\\begin{align}\n",
"\\mathbb{E}(f(X)g(Y)) = \\mathbb{E}(f(X))\\mathbb{E}((g(Y))\n",
"\\end{align}$$\n",
"\n",
"for all $f, g : \\mathbb{R} \\to \\mathbb{R}$ for which the last two expectations exist.\n",
":::"
]
},
{
"cell_type": "markdown",
"id": "1b0fc29e-0c7e-4f42-87ae-0bb3b2f3694b",
"metadata": {},
"source": [
"## Sums of discrete random variables\n",
"\n",
"The sum of independent discrete random variables can be expressed in terms of the convolution of the pmfs of the random variables.\n",
"\n",
"\n",
":::{prf:theorem} Convolution formula\n",
"\n",
"If $X$ and $Y$ are independent discrete random variables, then $Z = X + Y$ has pmf\n",
"\n",
"\n",
"$$\\begin{align}\n",
"\\mathbb{P}(Z = z) = \\sum_{x \\in \\text{Im} X} \\mathbb{P}(X = x)\\mathbb{P}(Y\n",
" = z - x).\n",
"\\end{align}$$\n",
"\n",
":::\n",
"\n",
"This can be extended to multiple random variables, by considering multiple convolutions in turn. However, there exist more convenient methods for summing independent random variables, such as probability generating functions, which are introduced in the next chapter."
]
},
{
"cell_type": "markdown",
"id": "01969e6b-8ba8-4413-9a9d-c3c0891f0d21",
"metadata": {},
"source": [
"## Indicator functions\n",
"\n",
"Indicator functions are a useful tool for problems involving counting of occurences of events.\n",
"\n",
"\n",
":::{prf:definition} Indicator functions\n",
"\n",
"The indicator function of an event $A$ is the random variable $1_{A}$ defined as\n",
" \n",
"$$\\begin{align}\n",
"1_A(\\omega) = \\begin{cases}\n",
"1 & \\text{ if } \\omega \\in A, \\\\\n",
"0 & \\text{ otherwise.}\n",
"\\end{cases}\n",
"\\end{align}$$\n",
"\n",
":::\n",
"\n",
"\n",
"One example use of indicator functions is the proof of the inclusion exclusion formula:\n",
" \n",
"$$\\begin{align}\n",
"\\mathbb{P}\\left(\\bigcup^N_{n=1} A_n\\right) = \\sum_{n} \\mathbb{P}(A_{n\n",
"}) - \\sum_\n",
"{n_1 < n_2}\\mathbb{P}(A_{n_1} \\cap A_{n_2})~+~...~+~(-1)^{N+1\n",
"}~\\mathbb{P}\\left(\\bigcap_n A_{n}\\right).\n",
"\\end{align}$$\n",
"\n",
"Letting $A = \\bigcup^N_{n=1} A_n$, considering that the indicator $1_A$ can be written as\n",
"\n",
"$$\\begin{align}\n",
"1_A &= 1 - \\prod_{n=1}^N \\left(1 - 1_{A_n}\\right)\\\\\n",
" &= \\sum_n 1_{A_n} - \\sum_{n_1 < n_2} 1_{A_{n_1}}1_{A_{n_2}} +~...~+ (-1\n",
" )^{N+1} 1_{A_1} 1_{A_2} ... 1_{A_N},\n",
"\\end{align}$$\n",
"\n",
"and taking expectations proves the inclusion-exclusion formula."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv-rw",
"language": "python",
"name": "venv-rw"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}