% vim: tw=50
% 12/03/2022 11AM

\noindent
Goal:
\[ f(x) = \begin{cases}
    \frac{1}{\mathrm{area}(A)} & x \in A \\
    0 & x \not\in A
\end{cases} \]
(in higher dimensions, $\mathrm{volume}(A)^{-1}$)
\myskip
Rewrite as
\[ f(x) = \frac{\mathbbm{1}_A}{\mathrm{area}(A)} \]
Let $U_1, U_2, \dots$ IID uniform on $[0, 1]^d$
and let $N = \min\{n : U_n \in A\}$.

\begin{claim*}
    $U_N$ is uniform on $A$. (i.e. has density
    $f$)
\end{claim*}

\begin{proof}
    Note $\PP(N < \infty) = 1$ if
    $\mathrm{area}(A) > 0$. \\
    \ul{Goal}:
    \[ \PP(U_n \in B) = \int_B f(x) \dd x =
    \frac{\mathrm{area}(B)}{\mathrm{area}(A)} \]
    for all $B \subset A$ with a well-defined
    area.
    \begin{align*}
        \PP(U_n \in B)
        &= \sum_{n \ge 1} \PP(U_n \in B, N = n) \\
        &= \sum_{n \ge 1} \PP(U_1 \not\in A,
        \dots, U_{n - 1} \not\in A, U_n \in B) \\
        &= \sum_{n \ge 1} \PP(U_1 \not\in A)^{n -
        1} \PP(U_n \in B) \\
        &= \sum_{n \ge 1} (1 -
        \mathrm{area}(A))^{n - 1} \times
        \mathrm{area}(B) \\
        &= \frac{\mathrm{area}(B)}{1 - (1 -
        \mathrm{area}(A))} \\
        &=
        \frac{\mathrm{area}(B)}{\mathrm{area}(A)}
    \end{align*}
\end{proof}

\myskip
Idea: $X$ a continuous random variable on $[0,
1]$, density $f$ is \emph{bounded}. Let
\[ A = \{(x, y) : x \in [0, 1], y \le f_X(x)\} \]
i.e. shaded region
\begin{center}
    \includegraphics[width=0.6\linewidth]
    {images/720cb606a32911ec.png}
\end{center}
Let $U = (U^{(1)}, U^{(2)})$ be uniform on $A$.
Then claim: $U^{(1)} \sim X$. \\
Why?
\begin{align*}
    \PP(U^{(1)} \le u)
    &= \PP(\text{in relevant area}) \\
    &= \mathrm{area}(\{x, y\} : x \le u, y \le
    f_X(x)) \\
    &= \int_0^u f_X(x) \dd x \\
    &= F_X(u)
\end{align*}
(note that the first and last expressions are the
CDFs of $U^{(1)}$ and $X$ respectively) \\
Usage: in higher dimension. \\
$X$ a continuous random variable on $[-K, K]^d$
with density bounded. Let
\[ A = \{(\bf{x}, y) : x \in [-K, K]^d, y \le
f_X(x)\} \subset \RR^{d + 1} \]
Let $U = (\bf{U}, U^+)$. Then $\bf{U} \sim X$.
(the proof is similar).

\subsubsection*{Multivariate Normals / Gaussians}

\begin{definition*}
    A random variable is \emph{Gaussian} if $X
    \sim \mathrm{N}(\mu, \sigma^2)$.
\end{definition*}

\noindent
Motivation: $X, Y$ independent Gaussian. Then $bX
+ cY$ is Gaussian ($*$). \\
Exercise: there exist joint random variables $(X,
Y)$ such that both $X, Y$ are Gaussian, but $X +
Y$ not Gaussian. \myskip
Question: Can we have dependent $X, Y$ such that
($*$) still holds?

\begin{definition*}
    Random vector $(X, Y)$ is \emph{Gaussian} if
    $bX + cY$ are Gaussian for all $b, c \in \RR$,
    i.e. $bX + cY \sim \mathrm{N}(??, ??)$.
\end{definition*}

\noindent
Consequences:
\[ \EE[bX + cY] = b\EE[X] + c\EE[Y] \]
\[ \mathrm{Var}(bX + cY) = b^2 \mathrm{Var}(X) +
c^2 \mathrm{Var}(Y) + 2bc \mathrm{Cov}(X, Y) \]

\subsubsection*{Linear Algebra Rewrite}

Random vector $X = (X_1, \dots, X_n) \in \RR^n$ is
\emph{Gaussian} if $u^\top X$ is Gaussian
$\forall\,\,u \in \RR^n$. Write $\mu = \EE[X] \in
\RR^n$. \\
Covariance matrix:
\[ V = (\mathrm{Cov}(X_i, X_j))_{i, j = 1}^n \in
\RR^n \times \RR^n \]
i.e. for $n = 2$:
\[ V =
\begin{pmatrix}
    \mathrm{Var}(X) & \mathrm{Cov}(X, Y) \\
    \mathrm{Cov}(Y, X) & \mathrm{Var}(Y)
\end{pmatrix}
\]
(note $V$ is symmetric). In fact $u^\top X \sim
\mathrm{N}(u^\top \mu, u^\top Vu)$.

\subsubsection*{MGFs in One Direction (Recap)}

Distribution of $X \in \RR$ determined by function
$m_X(\theta) = \EE[e^{\theta X}]$, $\theta \in
(-\eps, \eps)$.

\subsubsection*{MGFs in $\RR^n$}

Distribution of $X \in \RR^n$ determined by
\[ m_X(u) = \EE[e^{u^\top X} \qquad u \in (-\eps,
\eps)^n \]
If $X$ Gaussian, then
\[ m_X(u) = \exp \left( u^\top \mu + \half u^\top
Vu \right) \]
Logical overview: $X \in \RR^n$ Gaussian
\begin{itemize}
    \item distribution defined by MGF
    \item MGF defined by $\mu$ and $V$
\end{itemize}
\[ \implies \text{distribution of $X$ defined by
$\mu$ and $V$} \]

\begin{remark*}
    Density:
    \[ f_X(x) = \frac{1}{(2\pi)^{n/2}}
    \frac{1}{\sqrt{\det(V)}} \exp \left( -\half(x
    - \mu)^\top V(x - \mu) \right)  \]
\end{remark*}

\noindent
Return to $n = 2$: For a Gaussian vector  $(X_1,
X_2)$
\[ \text{Independent} \iff \mathrm{Cov}(X_1, X_2)
= 0 \]
(Note that the backwards direction is not true in
general!)
\myskip
Why useful? Imagine $X_1, X_2$ describe real-world
parameters, for example height vs 1km running
time.
\begin{itemize}
    \item Independence would be an interesting
        conclusion
    \item $\mathrm{Cov}(?, ?)$ can be sampled.
\end{itemize}
