% vim: tw=50
% 25/01/2022 10AM

\begin{proof}[(weaker version)]
    \[ \log(n!) = \log 2 + \log 3 + \cdots + \log n .\]
    \begin{center}
        \includegraphics[width=0.6\linewidth]
        {images/2778fac67de211ec.png}
    \end{center}
    \[ \ub{\textcolor{blue}{\int_1^n \log x \dd
    x}}_{\text{``Upper integral''}} \le
    \log(n!) \le \ub{\textcolor{red}{\int_1^{n + 1}
    \log x \dd x}}_{\text{``Lower integral''}} \]
    \[ \ub{n \log n - n = 1}_{\sim n \log n} \le
    \log (n!) \le \ub{(n + 1)\log (n + 1) -
    n}_{\sim n \log n} \]
    Hence $\log(n!) \sim n \log n$.
\end{proof}

\noindent
Key idea: \emph{Sandwiching} between lower/upper
integrals. \\
Useful:
\begin{itemize}
    \item $\log x$ is increasing
    \item $\log x$ has nice integral!
\end{itemize}

\subsubsection*{(Ordered) Compositions}

A \emph{composition} of $m$ with $k$ parts is
sequence $(m_1, \dots, m_k)$ of non-negative
integers with
\[ m_1 + \cdots + m_k = m .\]
For example, $3 + 0 + 1 + 2 = 6$. Bijection
between compositions and sequences of $m$ stars
and $k - 1$ dividers (stars and bars). So number
of compositions is ${m + k - 1 \choose m}$. \\
Comments: Q11 on example sheet 1.

\subsubsection*{Properties of Probability Measures}

$(\Omega, \mathcal{F}, \PP) \leftarrow$
Probability space
\begin{itemize}
    \item P1:
        \[ \PP : \mathcal{F} \to [0, 1] \]
    \item P2: $\PP(\Omega) = 1$.
    \item P3:
        \[ \PP \left( \bigcup_{n \ge 1} A_n
        \right) = \sum_{n \ge 1} \PP(A_n) \]
        $(A_n)_{n \ge 1}$ disjoint. ``Countable
        additivity''.
\end{itemize}

\subsubsection*{(1) Countable sub-additivity}

$(A_n)_{n \ge 1}$ sequence of events in
$\mathcal{F}$. Then
\[ \PP \left( \bigcup_{n \ge 1} A_n \right) \le
\sum_{n \ge 1} \PP(A_n) .\]
Intuition: this sum can ``double count'' some
sub-events.

\begin{proof}
    Idea: rewrite $\bigcup_{n \ge 1} A_n$ as a
    \emph{disjoint} union. Define $B_1 = A_1$ and
    $B_n = A_n \setminus (A_1 \cup \cdots \cup
    A_{n - 1})$ for $n \ge 2$ (which is in
    $\mathcal{F}$ by example sheet). So
    \begin{itemize}
        \item $\bigcup_{n \ge 1} B_n = \bigcup_{n
            \ge 1} A_n$
        \item $(B_n)_{n \ge 1}$ disjoint (by
            construction)
        \item $B_n \subseteq A_n \implies \PP(B_n)
            \le \PP(A_n)$ (by example sheet)
    \end{itemize}
    Hence
    \[ \PP \left( \bigcup_{n \ge 1} A_n \right) =
    \PP \left( \bigcup_{n \ge 1} B_n \right) =
    \sum_{n \ge 1} \PP(B_n) \le \sum_{n \ge 1}
    \PP(A_n) .\]
\end{proof}

\subsubsection*{(1) Continuity}

$(A_n)_{n \ge 1}$ is increasing sequence of events
in $\mathcal{F}$ i.e. $A_n \subseteq A_{n + 1}$.
Then $\PP(A_n) \le \PP(A_{n + 1})$. So $\PP(A_n)$
converges as $n \to \infty$. (Because bounded and
increasing.) In fact, $\lim_{n \to \infty}
\PP(A_n) = \PP \left( \bigcup_{n \ge 1} A_n
\right)$.

\begin{proof}
    Re-use the $B_n$s!
    \begin{itemize}
        \item $\bigcup_{k = 1}^n B_k = A_n$
            (disjoint union)
        \item $\bigcup_{n \ge 1} B_n = \bigcup_{n
            \ge 1} A_n$
    \end{itemize}
    \[ \PP(A_n) = \sum_{k = 1}^n \PP(B_k) \to
    \sum_{k \ge 1} \PP(B_k) \]
    \[ \PP \left( \bigcup_{n \ge 1} A_n \right) =
    \PP \left( \bigcup_{n \ge 1} B_n \right) =
    \sum_{n \ge 1} \PP(B_n) \]
\end{proof}

\noindent Try Q6.

\subsubsection*{(3) Inclusion-Exclusion Principle}

Background: $\PP(A \cup B) = \PP(A) + \PP(B) -
\PP(A \cap B)$. \\
Similarly: for $A, B, C \in \mathcal{F}$
\[ \PP(A \cup B \cup C) = \PP(A) + \PP(B) + \PP(C)
- \PP(A \cap B) - \PP(B \cap C) - \PP(C \cap A) +
\PP(A \cap B \cap C) .\]

\begin{theorem*}[Inclusion Exclusion Principle]
    Let $A_1, A_2, \dots, A_n \in \mathcal{F}$.
    Then:
    \begin{align*}
        \PP \left( \bigcup_{i = 1}^n A_i \right)
        &= \sum_{i = 1}^n \PP(A_i) - \sum_{1 \le
        i_1 < i_2 \le n} \PP(A_{i_1} \cap A_{i_2})
        + \sum_{1 \le i_1 < i_2 < i_3 \le n}
        \PP(A_{i_1} \cap A_{i_2} \cap A_{i_3}) \\
        &\,\,\,\,\, - \cdots + (-1)^{n + 1}
        \PP(A_1 \cap \cdots \cap A_n)
    \end{align*}
    Or, abbreviated:
    \[ \PP \left( \bigcup_{i = 1}^n A_i \right)
    = \sum_{\substack{I \subset \{1, \dots, n\}\\I
    \neq \emptyset}} (-1)^{|I| + 1} \PP \left(
    \bigcap_{i \in I} A_i \right) \]
\end{theorem*}
