\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
% \usepackage{amscd, amsfonts, amsmath, amssymb, amstext, amsthm, caption, epsfig, fancyhdr, float, graphicx, latexsym, mathtools, multicol, multirow, algorithm, chngcntr}
\usepackage[english]{babel}
\usepackage{booktabs}

\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subfig}
\usepackage{xspace}
\usepackage{fourier}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage{tkz-graph}
\usetikzlibrary{automata,arrows,positioning,calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{backgrounds}
\usetikzlibrary{calc}
\usetikzlibrary{shapes}
\usetikzlibrary{mindmap}
\usetikzlibrary{decorations.text}
\usetikzlibrary{snakes}

% \theoremstyle{definition} % insert bellow all blocks you want in normal text
% \newtheorem{definition}{Definition}

% tikzmark command, for shading over items
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
    text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20,
    text width=5em, text centered, rounded corners]
\tikzstyle{line} = [draw]
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
    minimum height=2em]

\usepackage[most]{tcolorbox}

\setbeamertemplate{blocks}[rounded][shadow=true] % use rounded blocks with standard beamer shadow

% Distributions.
\newcommand*{\UnifDist}{\mathsf{Unif}}
\newcommand*{\ExpDist}{\mathsf{Exp}}
\newcommand*{\DepExpDist}{\mathsf{DepExp}}
\newcommand*{\GammaDist}{\mathsf{Gamma}}
\newcommand*{\LognormalDist}{\mathsf{LogNorm}}
\newcommand*{\WeibullDist}{\mathsf{Weib}}
\newcommand*{\ParetoDist}{\mathsf{Par}}
\newcommand*{\NormalDist}{\mathsf{Norm}}

\newcommand*{\GeometricDist}{\mathsf{Geom}}
\newcommand*{\NegBinomialDist}{\mathsf{NegBin}}
\newcommand*{\PoissonDist}{\mathsf{Poisson}}
\newcommand*{\BivariatePoissonDist}{\mathsf{BPoisson}}
\newcommand*{\CyclicalPoissonDist}{\mathsf{CPoisson}}

\newcommand*{\iid}{\textbf{iid}\@\xspace}
\newcommand*{\pdf}{\textbf{pdf}\@\xspace}
\newcommand*{\cdf}{\textbf{cdf}\@\xspace}
\newcommand*{\pmf}{\textbf{pmf}\@\xspace}
\newcommand*{\abc}{{\textbf{abc}}\@\xspace}
\newcommand*{\smc}{\textbf{smc}\@\xspace}
\newcommand*{\mcmc}{\textbf{mcmc}\@\xspace}
\newcommand*{\ess}{\textbf{ess}\@\xspace}
\newcommand*{\mle}{\textbf{mle}\@\xspace}
\newcommand*{\bic}{\textbf{bic}\@\xspace}
\newcommand*{\kde}{\textbf{kde}\@\xspace}
\newcommand*{\glm}{\textbf{glm}\@\xspace}
\newcommand*{\xol}{\textbf{xol}\@\xspace}
\newcommand*{\cpu}{\textbf{cpu}\@\xspace}
\newcommand*{\gpu}{\textbf{gpu}\@\xspace}
\newcommand*{\arm}{\textbf{arm}\@\xspace}

\def \si {\sigma}
\def \la {\lambda}
\def \al {\alpha}
% \def\e*{\end{eqnarray*}}
\def \di{\displaystyle}

\def \E{\mathbb E}
\def \N{\mathbb N}
\def \Z{\mathbb Z}
\def \NZ{\mathbb{N}_0}
\def \I{\mathbb I}
\def \w{\widehat}
\def \P {\mathbb P}
\def \V{\mathbb V}

\newcommand{\CL}{\mathbb{C}}
\newcommand{\RL}{\mathbb{R}}
\newcommand{\nat}{{\mathbb N}}
\newcommand{\Laplace}{\mathscr{L}}
\newcommand{\e}{\mathrm{e}}
\newcommand{\ve}{\bm{\mathrm{e}}} % vector e

\renewcommand{\L}{\mathcal{L}} % e.g. L^2 loss.

\newcommand{\ih}{\mathrm{i}}
\newcommand{\oh}{{\mathrm{o}}}
\newcommand{\Oh}{{\mathcal{O}}}
\newcommand{\Exp}{\mathbb{E}}

\newcommand{\Norm}{\mathcal{N}}
\newcommand{\LN}{\mathcal{LN}}
\newcommand{\SLN}{\mathcal{SLN}}

\renewcommand{\Pr}{\mathbb{P}}
\newcommand{\Ind}{\mathbb I}
\newcommand\bfsigma{\bm{\sigma}}
\newcommand\bfSigma{\bm{\Sigma}}
\newcommand\bfLambda{\bm{\Lambda}}
\newcommand{\stimes}{{\times}}
\def \limsup{\underset{n\rightarrow+\infty}{\overline{\lim}}}
\def \liminf{\underset{n\rightarrow+\infty}{\underline{\lim}}}

% vertical separator macro
\newcommand{\vsep}{
  \column{0.0\textwidth}
    \begin{tikzpicture}
      \draw[very thick,black!10] (0,0) -- (0,7.3);
    \end{tikzpicture}
}
\newcommand\blfootnote[1]{%
  \begingroup
  \renewcommand\thefootnote{}\footnote{#1}%
  \addtocounter{footnote}{-1}%
  \endgroup
}

% More space between lines in align
% \setlength{\mathindent}{0pt}

% Beamer theme
\usetheme{ZMBZFMK}
\usefonttheme[onlysmall]{structurebold}
\mode<presentation>
\setbeamercovered{transparent=10}

% align spacing
\setlength{\jot}{0pt}

\setbeamertemplate{navigation symbols}{}%remove navigation symbols

\title[BLOCKASTICS]{Blockchain miner's risk management}
\author{Pierre-O. Goffard}
\institute[ISFA]{Institut de Science Financières et d'Assurances\\
 \texttt{pierre-olivier.goffard@univ-lyon1.fr}
}
\date{\today}
% \titlegraphic{\includegraphics[width=2.5cm]{../../Figures/bfs_logo.png}}

\begin{document}
\begin{frame}
  \titlepage
\end{frame}
\begin{frame}
  \tableofcontents
\end{frame}

\section{Introduction}
\begin{frame}{Blockchain}
A decentralized data ledger made of blocks maintained by achieving consensus in a P2P network.
\begin{columns}
\begin{column}{0.5\textwidth}
% \small

\begin{itemize}
  \item Decentralized
  \item Public/private
  \item Permissionned/permissionless
  \item Immutable
  \item Incentive compatible
\end{itemize}
\end{column}
\begin{column}{0.5\textwidth}
\begin{center}
\begin{tikzpicture}[-, >=stealth', auto, semithick, node distance=01cm]
\tikzstyle{every edge}=[snake=expanding waves,segment length=1mm,segment angle=10, draw]

\tikzstyle{full node}=[circle, fill=tublue,draw=tublue,thick,text=black,scale=0.8]
\tikzstyle{light node}=[circle, fill=white,draw=tublue,thick,text=black,scale=0.8]
\node[full node]    (1)                     {};
\node[full node]    (2)[above right of=1]         {};
\node[full node]    (3)[above left of=1]         {};
\node[full node]    (4)[below of=1]         {};
\node[full node]    (5)[right of=4]         {};
\node[full node]    (6)[below of=4]         {};
\node[light node]    (7)[left of=1]         {};
\node[light node]    (8)[right of=2]         {};
\node[light node]    (9)[left of=4]         {};
\node[light node]    (10)[above right of=5]         {};
\node[light node]    (11)[ right of=5]         {};
\node[light node]    (12)[ below right of=5]         {};
% \node[light node]    (4)[above of=2]         {};
\path

(1) edge node{} (2)
    edge node{} (3)
    edge node{} (7)
    ;
\path
(5) edge node{} (10)
    edge node{} (11)
    edge node{} (12)
    ;
    \path
(4) edge node{} (5)
    edge node{} (1)
    edge node{} (9)
    edge node{} (6)
    ;
    \path
(2) edge node{} (8)
    ;
\end{tikzpicture}
\end{center}
\end{column}
\end{columns}

\vspace{0.2cm}
\begin{tcolorbox}[enhanced,drop shadow, title=Focus of the talk]
Public and permissionless blockchain equipped with the Proof-of-Work protocol.
\end{tcolorbox}
\end{frame}

\begin{frame}{Consensus protocols}
The mechanism to make all the nodes agree on a common data history.\\
\vspace{0.3cm}
The three dimensions of blockchain systems analysis
\begin{enumerate}
  \item Efficiency
  \begin{itemize}
    \item Throughputs
    \item Transaction confirmation time
  \end{itemize}
  \item Decentralization
  \begin{itemize}
    \item Fair distribution of the accounting right
  \end{itemize}
  \item Security
  \begin{itemize}
    \item Resistance to attacks
  \end{itemize}
\end{enumerate}
\footnotesize
\begin{thebibliography}{1}
\bibitem{Fu2020}
X.~Fu, H.~Wang, and P.~Shi, ``A survey of blockchain consensus algorithms:
  mechanism, design and applications,'' {\em Science China Information
  Sciences}, vol.~64, nov 2020.
\end{thebibliography}
\end{frame}
\begin{frame}{Applications of blockchain: Cryptocurrency}
\begin{columns}
\begin{column}{0.5\textwidth}

{\footnotesize
\begin{thebibliography}{1}
\bibitem{Na08}
S.~Nakamoto, ``Bitcoin: A peer-to-peer electronic cash system.'' Available at
  \href{https://bitcoin.org/bitcoin.pdf}{https://bitcoin.org/bitcoin.pdf},
  2008.
\end{thebibliography}
}
\end{column}
\begin{column}{0.5\textwidth}  %%<--- here
    \begin{center}
     \includegraphics[width=0.5\textwidth]{../../Figures/bitcoin-6284869_1920.png}
     \end{center}
\end{column}
\end{columns}

\begin{itemize}
  \item Transaction anonymity
  \item Banking and reliable currency in certain regions of the world
  \item Money Transfer worldwide (at low fare)
  \item No need for a thrusted third party
\end{itemize}
\end{frame}
\begin{frame}{Decentralized finance}
DEFI creates new financial architecture
\begin{columns}
\begin{column}{0.5\textwidth}
\begin{itemize}
\item[+] Non custodial
\item[+] Anonymous
\item[+] Permisionless
\item[+] openly auditable
\end{itemize}
\end{column}
\begin{column}{0.5\textwidth}
\begin{itemize}
\item[-] Unregulated
\item[-] Tax evasion
\item[-] Fraud
\item[-] Money laundering
\end{itemize}
\end{column}
\end{columns}
\vspace{0.5cm}
Extends the Bitcoin promises to more complex financial operations
\begin{itemize}
  \item Collateralized lending
  \item Decentralized Exchange Platform
  \item Tokenized assets
  \item Fundraising vehicle (ICO, STO, ...)
\end{itemize}
\vspace{0.3cm}
\scriptsize
\begin{thebibliography}{1}

\bibitem{werner2021sok}
S.~M. Werner, D.~Perez, L.~Gudgeon, A.~Klages-Mundt, D.~Harz, and W.~J.
  Knottenbelt, ``Sok: Decentralized finance (defi),'' 2021.

\end{thebibliography}

\end{frame}
\begin{frame}{What's inside a block?}
A block consists of
\begin{itemize}
\item a header
\item a list of "transactions" that represents the information recorded through the blockchain.
\end{itemize}
The header usually includes
\begin{itemize}
\item the date and time of creation of the block,
\item the block height which is the index inside the blockchain,
\item the hash of the block
\item the hash of the previous block.
\end{itemize}
\begin{tcolorbox}[enhanced,drop shadow, title=Question]
What is the hash of a block?
\end{tcolorbox}
\end{frame}
\begin{frame}{Cryptographic Hash function}
\small
A function that maps data of arbitratry size (message) to a bit array of fixed size (hash value)
$$
h:\{0,1\}^\ast\mapsto \{0,1\}^d.
$$
A good hash function is
\begin{itemize}
\item deterministic
\item quick to compute
\item One way
\begin{itemize}
  \scriptsize
\item[$\hookrightarrow$] For a given hash value $\overline{h}$ it is hard to find a message $m$ such that
$$
h(m) = \overline{h}
$$
\end{itemize}
\item Colision resistant
\begin{itemize}
\item[$\hookrightarrow$] Impossible to find $m_1$ and $m_2$ such that
$$
h(m_1) = h(m_2)
$$
\end{itemize}
\item Chaotic
$$m_1\approx m_2\Rightarrow  h(m_1) \neq h(m_2)$$
\end{itemize}
\end{frame}
\begin{frame}{SHA-256}
The SHA-256 function which converts any message into a hash value of $256$ bits.
\begin{tcolorbox}[enhanced,drop shadow, title=Example]
The hexadecimal digest of the message
$$
\texttt{Moritz Voss is the man}
$$
is
\footnotesize
$$
\texttt{50f3257a3d22a56247a8978fd2505e8cdd64e1cb06e52c941d09e234722dc275}
$$
\end{tcolorbox}
\end{frame}
\begin{frame}{Mining a block}
\begin{figure}[!ht]
    \includegraphics[width = \textwidth]{../../Figures/block_not_mined.png}
    \captionsetup{width=0.8\textwidth}
    \centering
    \caption{A block that has not been mined yet.}
    \label{fig:block_not_mined}
\end{figure}
\end{frame}
\begin{frame}{Mining a block}
The maximum value for a 256 bits number is
$$
T_\text{max} = 2^{256}-1 \approx 1.16e^{77}.
$$
Mining consists in drawing at random a nonce
$$
\text{Nonce} \sim \text{Unif}(\{0,\ldots, 2^{32}-1\}),
$$
until
$$
h(\text{Nonce}|\text{Block info})<T,
$$
where $T$ is referred to as the target.
\begin{tcolorbox}[enhanced,drop shadow, title=Difficulty of the cryptopuzzle]
$$
D = \frac{T_{\max}}{T}.
$$
\end{tcolorbox}

\end{frame}
\begin{frame}{Mining a block}
If we set the difficulty to $D = 2^4$ then the hexadecimal digest must start with at least $1$ leading $0$
\begin{figure}[!ht]
    \includegraphics[width = \textwidth]{../../Figures/block_mined.png}
    \captionsetup{width=0.8\textwidth}
    \centering
    \caption{A mined block with a hash value having on leading zero.}
    \label{fig:block_mined}
\end{figure}
The number of trial is geometrically distributed
\begin{itemize}
\item Exponential inter-block times
\item Lenght of the blockchain = Poisson process
\end{itemize}
\end{frame}
\begin{frame}{Bitcoin protocol}
\begin{itemize}
  \item One block every 10 minutes on average
  \item Depends on the hashrate of the network
  \item Difficulty adjustment every 2,016 blocks ($\approx$ two weeks)
  \item Reward halving every 210,000 blocks
\end{itemize}
Check out \url{https://www.bitcoinblockhalf.com/}
\begin{tcolorbox}[enhanced,drop shadow, title=Risky business]
Steady operational cost VS infrequent capital gains
\end{tcolorbox}
\end{frame}

\section{Insurance risk theory}
\begin{frame}{Cramer-Lunberg risk model}
\begin{columns}
\begin{column}{0.5\textwidth}
\scriptsize
The financial reserves of a nonlife insurance company is given by
\begin{equation*}
R_t = u +ct - \sum_{i = 1}^{N_t}U_i\text{, }t\geq0,
\end{equation*}
où
\begin{itemize}
  \item $u>0$ the initial reserves
  \item $c$ is the premium rate
  \item $(N_t)_{t\geq0}$ is the claim frequency up to time $t\geq0$.
  \begin{itemize}
    \scriptsize
    \item[$\hookrightarrow$]  Poisson process with intensity $\lambda$
  \end{itemize}
  \item The $U_i$'s are the claim amounts
  \begin{itemize}
    \scriptsize
    \item[$\hookrightarrow$] Nonnegative random variables, \textbf{i.i.d.}, and independent from $N_t$
  \end{itemize}
\end{itemize}
\end{column}
\begin{column}{0.5\textwidth}
\begin{tikzpicture}
  %Origin and axis
  \coordinate (O) at (0,0);
  \draw[->] (-0.5,0) -- (5.5,0) coordinate[label = {below:\scriptsize$t$}] (xmax);
  \draw[->] (0,-0.5) -- (0,4) coordinate[label = {right:\scriptsize$R_t$}] (ymax);
   %Initial reserves
  \draw (0,2) node[black,left] {\scriptsize$u$} node{};
 % % %Length of the honest chain
  \draw[thick, tublue,-] (0,2) -- (2,3) node[pos=0.5, above] {};
  \draw[thick, dashed, tublue] (2,3) -- (2,1) node[pos=0.5, left] {\scriptsize\color{black}$U_1$};
  \draw[thick, tublue] (2,1) -- (3,1.5) node[pos=0.5, above] {};
  \draw[thick, dashed, tublue] (3,1.5) -- (3, 0.5) node[pos=0.5, left] {\scriptsize\color{black}$U_2$};
  \draw[thick, tublue] (3,0.5) -- (5, 1.5) node[pos=0.5, above] {};
   \draw[thick, dashed, tublue] (5,1.5) -- (5, -0.5) node[pos=0.5,above left] {\scriptsize\color{black}$U_3$};

  %Block finding Times
  \draw (2,0) node[black,below] {\scriptsize$T_1$} node{ \color{black}$\bullet$};
  \draw (3,0) node[black,below] {\scriptsize$T_2$} node{ \color{black}$\bullet$};
  \draw (5,0) node[black,below left] {\scriptsize$\tau_u$} node{ \color{black}$\bullet$};
\end{tikzpicture}
\end{column}
\end{columns}

\end{frame}
\begin{frame}{Ruin probability}
\scriptsize
Define the ruin time as
$$
\tau_u = \inf\{t\geq0\text{ ; }R_t <0\}
$$
and the ruin probability as
$$
\psi(u,t) = \mathbb{P}(\tau_u < t)\text{ et }\psi(u) = \mathbb{P}(\tau_u < \infty)
$$
Find $u$ such that
$$
\mathbb{P}(\text{Ruin}) = \alpha\text{ (0.005)},
$$
with
$$
c=(1+\eta)\lambda\mathbb{E}(U),
$$
where
$$\eta>0\text{ (net profit condition)}$$
otherwise
$$\psi(u)=1.$$

\tiny
\begin{thebibliography}{1}

\bibitem{Asmussen_2010}
S.~Asmussen and H.~Albrecher, {\em Ruin Probabilities}.
\newblock {WORLD} {SCIENTIFIC}, sep 2010.

\end{thebibliography}

\end{frame}

\section{Application to blockchain miner risk management}
\begin{frame}{Dual risk model}
\begin{columns}
\begin{column}{0.5\textwidth}
\scriptsize
Consider a miner
\begin{itemize}
  \item of hashrate $p\in(0,1)$
  \item that owns $u\geq0$ at $t = 0$
  \item spends $c = \pi_W\cdot W\cdot p$ per time unit
  \item who finds $p \lambda$ blocks on average per time unit, where $\lambda$ is the average number of blocks found by the network
\end{itemize}
The wealth of such a miner is given by
$$
R_t = u - c\cdot t + N_t\cdot b,\text{ (Dual risk model)}
$$
où
\begin{itemize}
  \item $(N_t)_{t\geq0}$ is a Poisson process with intensity $p\cdot\lambda$
  \item $b$ is the block finding reward (6.25 BTC) \url{bitcoinhalf.com}
\end{itemize}
\end{column}
\begin{column}{0.5\textwidth}
\begin{tikzpicture}
  %Origin and axis
  \coordinate (O) at (0,0);
  \draw[->] (-0.5,0) -- (5.5,0) coordinate[label = {below:\scriptsize$t$}] (xmax);
  \draw[->] (0,-0.5) -- (0,4) coordinate[label = {right:\scriptsize$R_t$}] (ymax);
   %Initial reserves
  \draw (0,3) node[black,left] {\scriptsize$u$} node{};
 % % %Length of the honest chain
  \draw[thick, tublue,-] (0,3) -- (2,1) node[pos=0.5, above] {};
  \draw[thick, dashed, tublue] (2,1) -- (2,2) node[pos=0.5, above left] {\scriptsize\color{black}$b$};
  \draw[thick, tublue] (2,2) -- (3.5,0.5) node[pos=0.5, above] {};
  \draw[thick, dashed, tublue] (3.5,0.5) -- (3.5, 1.5) node[pos=0.5, above left] {\scriptsize\color{black}$b$};
  \draw[thick, tublue] (3.5,1.5) -- (5, 0) node[pos=0.5, above] {};

  %Block finding Times
  \draw (2,0) node[black,below] {\scriptsize$T_1$} node{ \color{black}$\bullet$};
  \draw (3.5,0) node[black,below] {\scriptsize$T_2$} node{ \color{black}$\bullet$};
  \draw (5,0) node[black,below] {\scriptsize$\tau_u$} node{ \color{black}$\bullet$};
\end{tikzpicture}
\end{column}
\end{columns}
\end{frame}
\begin{frame}{Expected profit if no failure}
\scriptsize

The ruin time is defined as
$$
\tau_u  = \inf\{t\geq0\text{ ; }R_t \leq0\}
$$
\begin{itemize}
  \item Risk measure
  $$
  \psi(u,t) = \mathbb{P}(\tau_u \leq t)
  $$
  \item Profitability measure
  $$
  V(u,t) = \mathbb{E}(R_t\mathbb{I}_{\tau_u > t})
  $$
\end{itemize}
\end{frame}
\begin{frame}{A miner's dilemma}
\scriptsize
Use $\psi$ and $V$ to compare mining solo to
\begin{itemize}
  \item pool mining
\tiny
  \begin{thebibliography}{1}

\bibitem{rosenfeld2011analysis}
M.~Rosenfeld, ``Analysis of bitcoin pooled mining reward systems,'' 2011.

\bibitem[Albrecher et~al.(2022)Albrecher, Finger, and
  Goffard]{albrecher:hal-03336851}
Hansj{\"o}rg Albrecher, Dina Finger, and Pierre-Olivier Goffard.
\newblock {Blockchain mining in pools: Analyzing the trade-off between
  profitability and ruin}.
\newblock to appear in Insurance; Mathematics and Economics, April 2022.
\newblock URL \url{https://hal.archives-ouvertes.fr/hal-03336851}.

\end{thebibliography}
  \item \scriptsize deviating from the prescribed protocol (selfish mining)

  \tiny
  \begin{thebibliography}{1}
  \bibitem{Eyal2014}
I.~Eyal and E.~G. Sirer, ``Majority is not enough: Bitcoin mining is
  vulnerable,'' in {\em Financial Cryptography and Data Security},
  pp.~436--454, Springer Berlin Heidelberg, 2014.

\bibitem[Albrecher and Goffard(2022)]{Hansjoerg2022}
Hansjoerg Albrecher and Pierre-Olivier Goffard.
\newblock On the profitability of selfish blockchain mining under consideration
  of ruin.
\newblock \emph{Operations Research}, 70(1):179--200, jan
  2022.
\newblock \url{10.1287/opre.2021.2169}.
\end{thebibliography}
\end{itemize}
Analytical expressions for
$$
\widehat{\psi}(u,t)= \mathbb{E}[\psi(u,T)]\text{ and }\widehat{V}(u,t)= \mathbb{E}[V(u,T)],
$$
where $T\sim\text{Exp}(t)$.
\end{frame}

\begin{frame}{Solo mining}
\scriptsize
\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (profit and ruin when mining solo)]
For $u\geq0$, with
\begin{equation*}
\widehat{\psi}(u,t) = e^{\rho^\ast u},
\end{equation*}
and
\begin{equation*}
\widehat{V}(u,t) = u+(p\lambda b-c)t\left(1-e^{\rho^\ast u }\right),
\end{equation*}
where $\rho^\ast$ is the only nonnegative solution of
\begin{equation}\label{eq:equation_rho}
-c\rho + p\lambda(e^{b\rho}-1) = 1/t.
\end{equation}
\end{tcolorbox}
\begin{tcolorbox}[enhanced,drop shadow, title=Lambert function]
The solution $\rho^\ast$ of \eqref{eq:equation_rho} is given by
\begin{equation*}
  \rho^{\ast}=-\frac{p \lambda t+1}{ct}
  -\frac{1}{b} \,{\rm W} \left[-\frac{p\lambda
    \,b}{c}\,{e^{-b\,\left(\frac{p \lambda t+1}{ct}\right)}}
  \right],
  \end{equation*}
  where $W(.)$ denotes the Lambert function.
\end{tcolorbox}
\end{frame}
\begin{frame}{Sketch of the proof}
\scriptsize
The time-horizon is random with $T\sim\text{Exp}(t)$, we condition upon the events occuring in $(0,h)$, with $h<u/c$ so that ruin cannot occur before $h$. Three possibilities
\begin{itemize}
  \item[(i)] $T>h$ and no blocks $(0,h)$
  \item[(ii)] $T<h$ and no blocks $(0,T)$
  \item[(iii)] One block found before $T$ and $h$
\end{itemize}
The expected profit $\widehat{V}(u,t)$ satisfies
\begin{eqnarray*}
  \widehat{V}(u,t)& =&e^{-h(1/t + p\lambda)}\,\widehat{V}(u-ch,t)+\int\limits_0^h\frac1t\, e^{-s(1/t + p\lambda)}\,(u-cs)ds\\
  &+&\int\limits_0^h p\lambda\, e^{-s(1/t + p\lambda)}\,\widehat{V}(u-cs+b,t)ds.
  \end{eqnarray*}
  \end{frame}
\begin{frame}{Sketch of the proof}
\scriptsize
Differentiating with respect to $h$ and setting $h=0$, we get
\begin{equation}\label{eq:ODE}
c\widehat{V}'(u,t) + \left(\frac{1}{t} +  p\lambda\right)\widehat{V}(u,t) - p\lambda \widehat{V}(u+b,t) - \frac{u}{t} =0,
\end{equation}
Equation \eqref{eq:ODE} is an advanced differential equation
\blfootnote{\tiny
 H.~L. Smith, {\em An introduction to delay differential equations with
  applications to the life sciences}.
\newblock Springer, New York, 2011.
}
with boundary conditions
$$
\widehat{V}(0,t) = 0 \text{ such that } 0\leq \widehat{V}(u,t)\leq u-ct+p\lambda b t \text{ for }u>0.
$$
Consider solutions of the form
\begin{equation}\label{eq:potential_solution}
\widehat{V}(u,t) = Ae^{\rho u }+Bu + C,\text{ }u \ge 0,
\end{equation}
where $A, B,C$ and $\rho$ are constants to be determined. Substituting \eqref{eq:potential_solution} in \eqref{eq:ODE} together with boundary conditions
\begin{equation*}
\begin{cases}
0&=ct\rho + \left(1+p\lambda t\right)-p\lambda te^{\rho b}, \\
0&= B\left(1+tp\lambda\right)-p\lambda tB - 1,\\
0&=Bct+C(1+tp\lambda) - p\lambda t Bb-p\lambda tC, \\
0&=A+C.
\end{cases}
\end{equation*}
\end{frame}
\begin{frame}{Sketch of the proof}
\scriptsize
We get $A = -t(p\lambda b - c)$, $B = 1$, $C = t(p\lambda b - c)$ and $\rho$ verifies
$$
c\rho + \left(1+p\lambda t\right)-p\lambda te^{\rho b} = 0,
$$
The latter has two solutions on the real line, one negative and the other is positive. As $A<0$, we must take  $\rho^\ast<0$ to ensure that $\widehat{V}(u,t)>0$. Substituting $A,B,C$ and $\rho^{\ast}$ in \eqref{eq:potential_solution} yields the result.\\

Similarly, the ruin probability satisfies
\begin{equation*}\label{psii}
c\widehat{\psi}'(u,t)+(p \lambda+1/t)\,\widehat{\psi}(u,t)-p \lambda\,\widehat{\psi}(u+b,t)=0
\end{equation*}
with initial condition $\widehat{\psi}(0,t)=1$ and boundary condition $\lim_{u\to\infty}\widehat{\psi}(u,t)=0$.
\end{frame}
\begin{frame}{Mining pool?}
\scriptsize
Let $I\subset\{1,\ldots, n\}$ be a set of miners with cumulated hashpower
$$
p_I = \sum_{i\in I }p_i,
$$
\begin{itemize}
  \item A pool manager coordinates the joint effort
  \item Miners show their work by submitting partial solutions (\textit{share})
\end{itemize}
The pool manager chooses
\begin{itemize}
  \item the participant remuneration system
  \item the relative difficulty $q\in(0,1)$ of finding a \textit{share} VS finding a proper solution
  \item the amount of management fees $f$
  \end{itemize}
\end{frame}
\begin{frame}{Remuneration system}
\scriptsize
Miners must be compensated pro-rata to their contribution to the mining effort.
\begin{tcolorbox}[enhanced,drop shadow, title=Proportional scheme]
A \text{round} is the time elapsed between two block discovery
\begin{itemize}
  \item $s_i$ is the number of \textit{shares} submitted by $i\in I$ during the \textit{round}
  \item Each miner receives
  $$
  (1-f)\cdot b\cdot\frac{s_i}{\sum_{i\in I}s_i},
  $$
  at the end the round, where $f$ is the pool manager's cut.
  \item The system is deemed fair if $\frac{s_i}{\sum_{i\in I}s_i}\approx\frac{p_i}{\sum_{i\in I}p_i}$
\end{itemize}

\end{tcolorbox}
\end{frame}
\begin{frame}{What's wrong about going proportional}
\scriptsize
\begin{tcolorbox}[enhanced,drop shadow, title=Remarque]
This scheme is not incentive compatible
\end{tcolorbox}
\tiny
\begin{thebibliography}{1}

\bibitem{Schrijvers2017}
O.~Schrijvers, J.~Bonneau, D.~Boneh, and T.~Roughgarden, ``Incentive
  compatibility of bitcoin mining pool reward functions,'' in {\em Financial
  Cryptography and Data Security}, pp.~477--498, Springer Berlin Heidelberg,
  2017.

\end{thebibliography}
\scriptsize

\begin{itemize}
  \item The duration of \textit{rounds} is random
  \begin{itemize}
    \scriptsize
    \item[$\hookrightarrow$] A \textit{share} loses value when the \textit{round} last for too long $\Rightarrow$ \textit{pool hoping} \tiny
    \begin{thebibliography}{1}

\bibitem{rosenfeld2011analysis}
M.~Rosenfeld, ``Analysis of bitcoin pooled mining reward systems,'' 2011.

\end{thebibliography}
\scriptsize
    \item[$\hookrightarrow$] Apply a discount factor to \textit{shares} \tiny
    \begin{thebibliography}{1}
\bibitem{slush}
slush pool, ``Reward system specifications,'' 2021.
\end{thebibliography}
  \end{itemize}
  \item A miner may postpone the communication of a solution
  \begin{itemize}
    \scriptsize
    \item[$\hookrightarrow$] to wait for her proportion of submitted \textit{shares} to improve
  \end{itemize}
  \item No risk transfer from miner to pool manager
    \begin{itemize}
    \scriptsize
    \item[$\hookrightarrow$] $f$ must be small
  \end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{The Pay-per-Share (PPS) system}
\scriptsize
The manager pays
$$
w = (1-f)\cdot q \cdot b
$$
for every \textit{share} and keeps the block finding reward.
\vspace{1cm}
\begin{columns}
\begin{column}{0.5\textwidth}
Miner's wealth
$$
R_t^i = u_i-ct + M_t^i w,\text{ }t\geq0.
$$
where
\begin{itemize}
   \item $(M_t^i)_{t\geq0}$ is a Poisson process with intensity $p_i \mu= p_i\lambda / q$
   \item $\mu$ is the average number of \textit{shares} submitted by the network
\end{itemize}
\end{column}
\begin{column}{0.5\textwidth}
Manager's wealth
$$
R_t^I = u_I - M_t^I w+N_t^I b,\text{ }t\geq0.
$$
where
\begin{itemize}
   \item $(M_t^I)_{t\geq0}$ is a Poisson process with intensity $p_I\mu =p_I\lambda / q$
   \item $(N_t^I)_{t\geq0}$ is a Poisson process with intensity $p_I\lambda$
\end{itemize}
\end{column}
\end{columns}
\end{frame}
\begin{frame}{Pool manager's risk}
\scriptsize
Let us consider randomized rewards
$$
R_t= u - \sum_{i=1}^{M_t} W_i +\sum_{j=1}^{N_t} B_j,\text{ }t\geq0.
$$
where
\begin{itemize}
  \item $(M_t)_{t\geq0}$ and $(N_t)_{t\geq0}$ are Poisson processes with intensity $\mu^\ast=\mu- \lambda$ and $\lambda$
  \item $(W_i)_{i\geq0}$ and $(B_j)_{j\geq0}$ are two independent sequence of \iid exponential random variables with mean $w$ and $b^\ast = b-w$.
\end{itemize}
\begin{tcolorbox}[enhanced,drop shadow, title=Poisson process superposition]
A block discovery triggers the payment of a \textit{share} to the miners
\begin{itemize}
\item The intensity of $M_t$ is given by $\mu^\ast=\mu- \lambda$
\item The block finding reward is then $b^\ast = b-w$
\end{itemize}
A distinction is made here between jumps up and down.
\end{tcolorbox}
\end{frame}
\begin{frame}{Pool manager's risk}
\scriptsize
\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (Profits and loss of a pool manager)]
The ruin probability is given by
\begin{equation*}\label{psiexpe}
    \widehat{\psi}(u,t) = (1-Rw)  e^{-R u},\;u\ge 0,
\end{equation*}
and the expected wealth is
\begin{equation*}\label{Vcombexpe}
    \w{V}(u,t) = (1 - Rw)[w-t(\lambda b^\ast-\mu^\ast w)] e^{-R u}+u+t(\lambda b^\ast-\mu^\ast w),
\end{equation*}
where $R$ is the only solution to
\begin{equation*} \label{VLunde}
    -(t^{-1}+\lambda+\mu^\ast)+\lambda(1+b^\ast r)^{-1}+\mu^\ast(1-wr)^{-1}=0,
\end{equation*}
with positive real part.
\end{tcolorbox}
\tiny
  \begin{thebibliography}{1}

\bibitem{albrecher2021blockchain}
H.~Albrecher, D.~Finger, and P.-O. Goffard, ``Blockchain mining in pools:
  Analyzing the trade-off between profitability and ruin,'' 2021.

\end{thebibliography}
\end{frame}
\begin{frame}[allowframebreaks]{Sketch of the proof}
\scriptsize
Conditionning upon the events that occur during $(0,h)$. Four possibilities
\begin{itemize}
  \item[(i)] $T>h$ and no jumps $(0,h)$
  \item[(ii)] $T<h$ and no jumps $(0,T)$
  \item[(iii)] an upward jump $(0,h)$
  \item[(iv)] a downward jump $(0,h)$
\end{itemize}
  \begin{eqnarray*}\label{neu0}
      \w{V}(u,t)&=& e^{-(\frac{1}{t}+\lambda+\mu^\ast)h}\w{V}(u,t) + \frac{1}{t}\int_0^h e^{-{s}/{t}}e^{-(\lambda +\mu^\ast) s} u\,ds\\
      & +& \lambda\int_0^he^{-\lambda s} e^{-({1}/{t}+\mu^\ast) s} \int_0^\infty\w{V}(u+x,t)\,dF_{B}(x)\,ds\\
      &  +&\mu^\ast \int_0^he^{-\mu^\ast s} e^{-({1}/{t}+\lambda) s}\int_0^u \w{V}(u-y,t) \,dF_W(y)\,ds.
  \end{eqnarray*}
  Differentiating with respect to $h$ and letting $h\rightarrow 0$, yields
  \begin{equation} \label{inteq}
    \lambda\int_0^\infty\w{V}(u+x,t)\,dF_{B}(x)-(\lambda+\mu^\ast+{1}/{t})\w{V}(u,t)+\mu^\ast\int_0^u \w{V}(u-y,t) \,dF_W(y)+{u}/{t}=0,\quad u\ge 0,
  \end{equation}
  with boundary conditions $\w{V}(u,t)=0$ pour tout $u<0$ et $0\leq\w{V}(u,t)\leq u+(\lambda b^\ast - \mu^\ast w)t$. Consider solutions of the form
  $$
  Ce^{-ru}+d_1u+d_0
  $$
  \begin{itemize}
    \item Gathering the terms in factor of $e^{-r u}$ yields an equation for $r$ with
    $$
    -(t^{-1}+\lambda+\mu^\ast)+\lambda(1+b^\ast r)^{-1}+\mu^\ast(1-wr)^{-1}=0
    $$
    with nonnegative solution $R>0$, negative is impossible because $0\leq\w{V}(u,t)\leq u+(\lambda b^\ast - \mu^\ast w)t$
    \item Gathering the terms in factor of $u$, yields $d_1 = 1$
    \item Gathering the terms in factor of $1$, yields
    $$
    d_0 = t(\lambda b^\ast-\mu^\ast w)
    $$
    \item Gathering the terms in factor of $e^{-u/w}$, yields
    $$
    C = (1 - Rw)[w-t(\lambda b^\ast-\mu^\ast w)]
    $$
  \end{itemize}
\end{frame}
\begin{frame}{Problem related to mining pools}
\begin{itemize}
  \item Arm race, ramping electricity consumption and e-waste generation
\tiny
\begin{thebibliography}{1}

\bibitem{bertucci2020mean}
C.~Bertucci, L.~Bertucci, J.-M. Lasry, and P.-L. Lions, ``Mean field game
  approach to bitcoin mining,'' 2020.

\bibitem{Alsabah2018}
H.~Alsabah and A.~Capponi, ``Bitcoin mining arms race: R{\&}d with
  spillovers,'' {\em {SSRN} Electronic Journal}, 2018.

\end{thebibliography}
\end{itemize}
\begin{itemize}
  \item \normalsize A threat on decentralization?
\tiny
\begin{thebibliography}{1}

\bibitem{Cong2020}
L.~W. Cong, Z.~He, and J.~Li, ``Decentralized mining in centralized pools,''
  {\em The Review of Financial Studies}, vol.~34, pp.~1191--1235, apr 2020.

\bibitem{li2019mean}
Z.~Li, A.~M. Reppen, and R.~Sircar, ``A mean field games model for
  cryptocurrency mining,'' 2019.
\end{thebibliography}
\end{itemize}
\end{frame}
% \begin{frame}
% \cite{albrecher:hal-03336851,Hansjoerg2022}
% \bibliography{../../blockastics}
% \bibliographystyle{plainnat}
% \end{frame}

\end{document}


\documentclass[11pt]{article}
	\usepackage[fleqn]{amsmath}
	\usepackage{float}
	\usepackage{caption}
	\usepackage{graphicx}
	\usepackage[margin=1in]{geometry}
	\usepackage{color}
	\title{Project 2 Report}
	\author{Group 29: Feiyu Zheng(fz114) \& Xueyang Chen(xc186)}
	\date{\today}
\begin{document}
	\maketitle
	\section*{1. How do we do feature extraction?}
		We use each single pixel in the graph as a feature, and the name/key for each feature is its location. If it is a white space, we assign the value of this feature to 0, otherwise 1.

	\section*{2. How do we implement each algorithm?}
		\subsection*{Naive Bayes:}
			\flushleft{}Since we need to use Bayes Rule equation to predict the probabilities of each outcome(label), we have to implement it in the coding. For Baye Rule, \\(\textcolor{red}{a}) \textcolor{blue}{probability of outcome(specific label) given a feature set of a sample} is equal to the product of (\textcolor{red}{b}) \textcolor{blue}{probability of outcome(specific label)} and (\textcolor{red}{c}) \textcolor{blue}{probability of this data given outcome is a specific label} divided by (\textcolor{red}{d}) \textcolor{blue}{the probability of the data}.\\
			\flushleft{}Because we only need to know which outcome(label) has the greatest probability, we compare the value of each outcome(label) for the same data(sample). Since (\textcolor{red}{d}) \textcolor{blue}{the probabilities of the data} are always the same, we just need to compare the value of (\textcolor{red}{b}) \textcolor{blue}{probability of outcome(specific label)} times (\textcolor{red}{c}) \textcolor{blue}{probability of this data given outcome is a specific label}.\\
			\flushleft{}Because multiplying many probabilities together often results in underflow, we will instead compute log probabilities.\\

			\flushleft{}For (\textcolor{red}{b}) \textcolor{blue}{probability of outcome(specific label)}, we use the number of samples with specific label divided by total number of samples. Then, calculate its log value.\\

			\flushleft{}For (\textcolor{red}{c}) \textcolor{blue}{probability of this data given outcome is a specific label}, it is the same as the product of (\textcolor{red}{e}) \textcolor{blue}{the probability of each feature given a specific outcome(label)}. We calculate each (\textcolor{red}{e}) \textcolor{blue}{probability of a single feature given a specific probability(label)}, and then multiply their log values.\\

			\flushleft{}For (\textcolor{red}{e}) \textcolor{blue}{probability of a single feature given a specific probability(label)},  we count the total times a specific feature has value 0 with a specific label, and divided by the total number of samples with this specific label. Since we only have two possible values for each feature(0 and 1), if a specific feature has value 1, then we use 1 minus the probability we have above to get the answer. Lastly, we convert the value to log value.\\

			\flushleft{}{}We sum all log values we get above to get our log probability of a specific label for a data. The label with greatest probability is our final prediction.\\

			\flushleft{}When we do the training process, we use a smoothing parameter \textcolor{blue}{k} to improve the accuracy of prediction. We have a set of 10 different \textcolor{blue}{k} values, and each iteration runs with one k value. After 10 iterations, we assign \textcolor{blue}{k} to the value with best accuracy.

		\subsection*{Perceptron:}
			\flushleft{}For all training data, we pick them one by one to do the following training process:
			\begin{itemize}
				\item[(1)]For each training data, we have A features vectors and B labels. Then we initialize the weight as a BxA matrix which contains small values (0.5 in our project). Multiplying the weight matrix by the features vectors will yield a vector that contains a value corresponding to each label. Among these values, we choose the label with the largest value as our prediction
				\item[(2)] We compare our prediction with the actual answer and take different actions depending on the comparison result.\\
				\begin{itemize}
					\item[(a)] If the label we predict is right, then we don’t modify the weight and jump to the next picture.
					\item[(b)] If the label we predict is not the same with the actual label,
					\begin{itemize}
						\item[(i)] we increase the weight value used for the real label if the current result for the real label is less than zero.
						\item[(ii)] we decrease the weight value used for the prediction label if the current result for that label is greater than zero.
					\end{itemize}
				\end{itemize}
				\item[(3)] We keep doing the above two steps until the algorithm reaches the iteration limits we predefined or there is no weight value change for all training data.
			\end{itemize}

	\section*{3. The learning curve for each case.}
		\begin{figure}[H]
			\centering
			\includegraphics[scale=0.8]{Accuracy Digit (Naive Bayes).jpg}
			\caption{Accuracy of Using Naive Bayes on Digit Data}\label{fig:1}
		\end{figure}
		\begin{figure}[H]
			\centering
			\includegraphics[scale=0.8]{Accuracy Digit (Perceptron).jpg}
			\caption{Accuracy of Using Perceptron on Digit Data}\label{fig:1}
		\end{figure}
		\begin{figure}[H]
			\centering
			\includegraphics[scale=0.8]{Accuracy Face (Naive Bayes).jpg}
			\caption{Accuracy of Using Naive Bayes on Face Data}\label{fig:1}
		\end{figure}
		\begin{figure}[H]
			\centering
			\includegraphics[scale=0.8]{Accuracy Face (Perceptron).jpg}
			\caption{Accuracy of Using Perceptron on Face Data}\label{fig:1}
		\end{figure}
		\flushleft{}As above Figure 1-4 show, we can see that the accuracy goes up as we are using more and more training data and we can also see a trend that the amount of data needed to increase the accuracy is increasing as the accuracy keeps increasing. As we are getting higher and higher accuracy, it’s harder and harder to increase the accuracy by adding more training data.
		\flushleft{}The following Figure 5-7 are the visualization of trained weight in the perceptron algorithm. With 100\% training data, the algorithm can already classify some labels by some points and know the general shape of a type of images.

		\begin{figure}[H]
			\centering
			\includegraphics[scale=0.3]{Weight Visualization Digit 1.jpg}
			\caption{Perceptron Weight Visualization of Digit 1}\label{fig:1}
		\end{figure}
		\begin{figure}[H]
			\centering
			\includegraphics[scale=0.3]{Weight Visualization Digit 3.jpg}
			\caption{Perceptron Weight Visualization of Digit 3}\label{fig:1}
		\end{figure}
		\begin{figure}[H]
			\centering
			\includegraphics[scale=0.4]{Weight Visualization Face.jpg}
			\caption{Perceptron Weight Visualization of Face}\label{fig:1}
		\end{figure}

	\section*{4. Our observation on statistics.}
		\begin{figure}[H]
			\centering
			\includegraphics[scale=0.8]{Digit Average Training Time.jpg}
			\caption{Training Time of Perceptron and Naive Bayes When Using Digit Data}\label{fig:1}
		\end{figure}
		\begin{figure}[H]
			\centering
			\includegraphics[scale=0.8]{Face Average Training Time.jpg}
			\caption{Training Time of Perceptron and Naive Bayes When Using Face Data}\label{fig:1}
		\end{figure}
		\flushleft{}Figure 8-9 show the time needed for training. We can see that as the number of training data gets larger and larger, the time needed for perceptron algorithms increases much faster than the naive bayes.
		\flushleft{}In Figure 1-4, the gray lines show the standard deviation as the number of data points increases during training. We can see a general pattern that as the size of training data increases, the prediction error is getting smaller and smaller and for Naive Bayes, the prediction error is always 0 when using 100\% training data.

	\section*{5. What can be improved in the future if it does not work well or does not have a high accuracy}
		\flushleft{}We can choose the better features which are more related to the result. For instance, the number of non-white space in a row or column, or the location of the farest gray space in each line.

\end{document}


\documentclass[main.tex]{subfiles}
\begin{document}

\marginpar{Wednesday\\ 2020-4-22, \\ compiled \\ \today}

% Last time we considered the spontaneous breaking of a \emph{global} symmetry: we saw the appearance, corresponding to the breaking of the \(U(1)\) symmetry, of massless Goldstone bosons.
% Each broken generator has a corresponding Goldstone boson.

% We had a quadratic term in the Lagrangian, and a quartic term.

What would \(\mu^2<0\) physically mean? It would be a tachyonic particle.

The field \(\sigma (x)\) is called the \textbf{Higgs field}; the would-be Goldstone boson disappears yielding the longitudinal polarization of \(A_{\mu } (x)\).
% The Vacuum Expectation Value goes from 0 to \(v\): in this case we have broken the \(U(1)\) symmetry.

% The imaginary part of the field \(\phi \) corresponds to a massless scalar field.

% Every time we have a certain global symmetry described by a group \(G\) with generators \(t^{a}\), which is broken to a subgroup \(G'\) (which can also be just the identity) with generators \(t^{i}\), we can identify the broken generators with Goldstone bosons.

% We have the Dirac equation \(\qty(i \slashed{\partial} - m) \psi =0\), where \(\psi \) has a global \(U(1)\) symmetry.
% This can\emph{not} be generalized to a local \(U(1)\) symmetry, unless we introduce a compensating gauge field.

% Let us consider the Lagrangian from yesterday for the scalar field with a kinetic, quadratic and quartic term. Can we do \(\partial_{\mu } \to \DD_{\mu }\) as we did with QED, to generalize the \(U(1)\) symmetry of \(\phi \)?

% We can do it and encounter no issues.

% What if \(\mu^2<0\)? The result is surprising: we do as before, perturbing around the vacuum \(\phi = v\), writing \(\phi = v + \sigma (x) + i \eta (x)\).
% This is around pages 92--93 of the notes.

% We start from \(\phi \), which has 2 dof since it is a complex scalar, and \(A_{\mu }\), which also has 2 dof since it is a massless vector.

% We would expect to get the fields \(\sigma \) and \(\eta \): however, the field \(\eta \) does not appear, it is ``eaten up'' by the vector field \(A_{\mu }\).
% We only find a massive real scalar \(\sigma (x)\), which has 1 dof, and a massive vector boson \(A_{\mu }\), which has 3 dof.

% This is the \emph{transmutation}, the scalar degree of freedom is absorbed to a degree of freedom in the vector field.

We are curing two different problems: we have found massive gauge bosons, and removed the unphysical Goldstone bosons.

\subsubsection{A more general formulation: \(SU(2)\) symmetry breaking}

This section follows Peskin pretty closely \cite[sec.\ 16.2]{peskinConceptsElementaryParticle2019}.

We can repeat this in the general case, with the group \(G\) being broken to \(G'\). Suppose, for clarity, that this is \(SU(2)\) being broken to \(U(1)\).

The three vectors \(A^{a}_{\mu }\) generate rotations around the axes \(x^{a}\) respectively, as \(a = 1, 2, 3\).

The adjoint representation of \(SU(2)\) is given by three real scalar fields \(\phi^{a}\); their covariant derivative is given by
%
\begin{align}
\DD_{\mu } \phi^{a}
= \partial_{\mu } \phi^{a}
+ g \epsilon^{abc} A^{b}_{\mu } \phi^{c}
\,,
\end{align}
%
since the representation matrices in the adjoint representation are \((t^{b}_{G})_{ac} = i f^{abc}\).

We want to choose a potential \(V(\phi )\) which is minimized by a configuration with \(\expval{\abs{\phi^{a}}} = v\).
A vacuum for this potential is, for example, given by \(\phi^{a }= v \delta^{a3}\): it retains some rotational invariance (around the \(\hat{3}\) axis), but invariance for rotations around the other two axis is broken.

A perturbative expansion around such a vacuum will then be given by
%
\begin{align}
\phi (x) = \qty(\pi^{1} (x), \pi^{2}(x), v + h(x))
\,,
\end{align}
%
where \(\pi^{1, 2}\) are the would-be goldstone bosons, which will contribute to the longitudinal components of \(A^{1,2}_{\mu }\), the bosons which become massive.

On the other hand, \(A^{3}_{\mu } \) remains massless.
As we go to the unitary gauge we can eliminate \(\pi^{1, 2}\): so we get
%
\begin{align}
\phi (x) = (0, 0, v + h(x))
\,.
\end{align}

We know that
%
\begin{align}
\DD_{\mu } \phi^{a}
&= \partial_{\mu } h \delta^{3a}
+ g \epsilon^{abc} A^{b}_{\mu } \phi^{c}  \\
&= \partial_{\mu } h \delta^{3a}
+ g \epsilon^{ab3} A^{b}_{\mu } (v + h(x))
\,.
\end{align}

The kinetic term of \(\phi^{a}\) will then become:
%
\begin{align}
\frac{1}{2} \qty(\DD_{\mu } \phi^{a})^2
&= \frac{1}{2} \DD_{\mu } \left[\begin{array}{ccc}
0 & 0 & v+h
\end{array}\right]
\DD^{\mu } \left[\begin{array}{c}
0 \\
0 \\
v+h
\end{array}\right]  \\
&= \frac{1}{2} \qty[
    g \epsilon^{ab3} A^{b}_{\mu } (v+h)
    + \partial_{\mu } h \delta^{a3}
]^2  \marginnote{Square entails contraction of both \(a\) and \(\mu \).}\\
&= \frac{g^2 v^2}{2} \epsilon^{ab3} A^{b}_{\mu } \epsilon^{ad3} A^{d, \mu } + \mathcal{O}(h) \\
&= \frac{g^2 v^2}{2} \qty(A^{1}_{\mu } A^{\mu 1} + A^{2}_{\mu } A^{\mu 2 } ) + \mathcal{O}(h)
\,.
\end{align}

So, \(A^{1, 2}\) became massive, with mass \(M_W^2 = g^2 v^2\), while \(A^{3}\) remained massless.

As \(SU(2)\) is broken to \(U(1)\), the 3 generators \(A_{\mu }^{a}\), with \(a = 1, 2, 3\) are broken to give two massive vector bosons (\(W^{\pm}\)) and one massless vector boson (the photon), while the real field \(\sigma \) is the Higgs field.

The two \(W\) bosons are not actually the components \(A^{1, 2}\): instead, we choose them to be the eigenvalues of rotations around the \(z\) axis:
%
\begin{align}
W^{\pm}_{\mu } = \frac{1}{\sqrt{2}} \qty(A^{1}_{\mu } \mp i A^{2}_{\mu })
\,,
\end{align}
%
since the rotation matrix around the \(z\) axis in the spin-1 representation is given by
%
\begin{align}
J^{3} = \left[\begin{array}{ccc}
0 & -i & 0 \\
i & 0 & 0 \\
0 & 0 & 0
\end{array}\right]
\,,
\end{align}
%
whose eigenvectors are indeed \((1, \mp i, 0)\) with eigenvalues \(\pm 1\).

This is called the \textbf{Georgi-Glashow model}. It predicts two massive bosons of the \(V-A\) interaction.
However, it does not work well phenomenologically.

\subsubsection{Hypercharge: why the GG model does not work}

This was a computationally easy example to clarify what this mechanism looks like, not the one we actually will use: we will have to choose another symmetry group.

The issue lies with the fact that we are associating electric charge with the generator of rotations about \(\hat{3}\).
We know that an electron current can be turned into an electronic neutrino current, and that the neutrino is electrically neutral.
They must belong to the same isospin multiplet in order for this to happen.
Isospin (\(I\)) is what we call rotation in the three-dimensional space the \(SU(2)\) symmetry was initially defined in.
Rotation about the \(\hat{3}\) axis then corresponds to the operator \(I_3\); the algebra of these operators is that of a rotation representation, \([I_i, I_j] = i \epsilon_{ijk} I_k\).
When we say ``isospin multiplet'' we mean that the value of \(I^2 = j (j+1)\) is fixed; then the value of \(I_3\) will go from \(-j\) to \(j\).

We cannot have a doublet with only \(\nu \) and \(e^{-}\) because of the fact that the neutrino is neutral: the eigenvalues of the rotation about the \(3\) axis would have to be \(0\) and \(1\).
We need a particle with eigenvalue \(-1\) with respect to rotations about the \(\hat{3}\) axis, so with positive charge.

We then predict the existence of a heavy electron \(E^{+}\), such that the triplet looks like
%
\begin{align}
\left[\begin{array}{c}
E^{+} \\
\nu  \\
e^{-}
\end{array}\right]
\,,
\end{align}
%
where the eigenvalues of this rotation around the \(\hat{3}\) axis are \(-1, 0, 1 \) respectively.
This heavy electron was not observed; the experimental bound is at \(M_{E^{+}}\leq \SI{400}{GeV}\) currently.
We would expect to then see processes like \(u + E^{+} \to d + \nu \), but we do not.

\todo[inline]{Is the positron \(e^{+}\) not a candidate for this? Why do we say that this particle would need to be ``heavy''? Or are we already implicitly considering antiparticles maybe?}

This will be a way to unify electromagnetic and weak interactions, and we will get to use a single coupling constant for our new electroweak theory.

\subsection{Electroweak symmetry breaking}

The correct symmetry group for the electroweak theory, as Glashow showed in 1961, is
%
\begin{align}
SU(2)_{L} \otimes U(1) _{\text{hypercharge}}
\,,
\end{align}
%
where the hypercharge is usually denoted as \(Y\).
We have three vector fields for \(SU(2)\), which we call \(A_{\mu}^{i}\), and also a vector field for \(U(1)\): \(B_{\mu }\).
Note that these do not have a direct correspondence with the fields we get after SSB: hypercharge is different from electromagnetic charge.

The pair neutrino-electron is a \(I = 1/2\) doublet under \(SU(2) \times U(1)\), we will see that one component of this doublet has charge \(+\) while the other has charge 0: its transformation will look like
%
\begin{align}
\left[\begin{array}{c}
\nu_{L} \\
e^{-}_{L}
\end{array}\right]
\to
\underbrace{e^{-i \vec{\alpha} \cdot \vec{\sigma} / 2}}_{SU(2)}
\underbrace{e^{-i \beta  /2 }}_{U(1)}
\left[\begin{array}{c}
\nu_{L} \\
e^{-}_{L}
\end{array}\right]
\,.
\end{align}

The bosons in this theory start off as massless, and therefore the fields
%
\begin{align}
W^{\pm}_{\mu } = \frac{1}{\sqrt{2}}  \qty(A^{1}_{\mu } \mp i A^{2}_{\mu })
\,
\end{align}
%
are massless as well. However, we want massive \(W\) bosons with \(M_W \sim \SI{100}{Gev}\)!
At the end of the sixties Weinberg and Salam introduced the Higgs mechanism in this theory.
The idea is to interpret the scalar field as a \(I= 1/2\) representation of rotation: it will transform under the symmetries of the theory as
%
\begin{align}
\varphi =
\left[\begin{array}{c}
\varphi^{+} \\
\varphi^{0}
\end{array}\right]
\to
e^{i \vec{\alpha} \cdot \vec{\sigma} /2}
e^{i \beta / 2}
\left[\begin{array}{c}
\varphi^{+} \\
\varphi^{0}
\end{array}\right]
\,.
\end{align}

So, the lepton doublet has a charge \(-1/2\) with respect to the \(U(1)\) symmetry, while the field has a symmetry \(+1/2\).

Suppose the potential of the field reads:
%
\begin{align}
V(\phi ) = - \mu^2 \abs{\phi }^2 + \lambda \abs{\phi }^{4}
\,,
\end{align}
%
whose minimum is defined by
%
\begin{align}
0= - 2 \mu^2 \phi + 4 \lambda \phi \abs{\phi }^2
\,,
\end{align}
%
therefore the minimum is a sphere (since the two complex fields correspond to four real degrees of freedom) with \(\abs{\phi }^2 =  \abs{\phi^{+}}^2 + \abs{\phi^{0}}^2 = \mu^2 / 2 \lambda \); so we define \(v = \mu / \sqrt{\lambda }\).

Up to a rotation, the VEV of our field will be
%
\begin{align}
\expval{\phi }_{0} = \frac{1}{\sqrt{2}}
\left[\begin{array}{c}
0 \\
v
\end{array}\right]
\,.
\end{align}

This vacuum breaks the \(SU(2)_L \times U(1)_{Y}\) symmetry.
We can expand around it in the following manner:
%
\begin{align}
\phi (x)
=
\left[\begin{array}{c}
\pi^{+}(x) \\
\frac{v + h(x) + i \pi^{3}(x)}{\sqrt{2}}
\end{array}\right]
\,,
\end{align}
%
where \(\pi^{+} = (\pi^{1} + i\pi^{2}) / \sqrt{2}\) is a complex perturbation encompassing two real degrees of freedom.

As we did before, we can gauge away the unphysical Goldstone bosons \(\pi^{1, 2, 3}\); the real field \(h(x)\) remains.

How do the bosons of this theory \textbf{couple to fermions}? The couplings can only have specific forms, fixed by gauge invariance: the covariant derivative will read:
%
\begin{align}
\DD_{\mu } \Psi  =
\qty(\partial_{\mu }
- i g A^{a}_{\mu } I^{a}
- i g' B_{\mu } Y
)\Psi
\,,
\end{align}
%
where \(g\) and \(g'\) are the coupling of \(SU(2)\) weak isospin and \(U(1)\) hypercharge respectively; \(I^{a}\) are the generators of \(SU(2)\) in the \(SU(2)\) representation acting on \(\Psi \), and \(Y\) is the hypercharge, a scalar.

In principle, \(g\) and \(g'\) are independent, so we keep them distinct. Let us now apply \(\DD_{\mu } \) to the field \(\phi \) around the vacuum with only the \(h \) perturbation, as
%
\begin{align}
\DD_{\mu } \phi = \qty(\partial_{\mu }
- i g A^{a}_{\mu } I^{a}
- i g' B_{\mu } Y
) \left[\begin{array}{c}
0 \\
\frac{v + h(x)}{\sqrt{2}}
\end{array}\right]
\,,
\end{align}
%
of which we take the square norm, up to zeroth order in \(h\):
%
\begin{align}
\abs{\DD_{\mu } \phi }^2
&= \frac{1}{2} \left[\begin{array}{cc}
0 & v
\end{array}\right]
\qty(g A^{a}_{\mu } \frac{\sigma^{a}}{2} + g' B_{\mu } \frac{1}{2})
\qty(g A^{b, \mu } \frac{\sigma^{b}}{2} + g' B^{\mu } \frac{1}{2})
\left[\begin{array}{c}
0 \\
v
\end{array}\right] \qty(+ \mathcal{O}(h)) \\
&= \frac{1}{2} \underbrace{ g^2v^2  \frac{1}{4}
\qty(A^{1}_{\mu } A^{1, \mu } + A^{2}_{\mu } A^{2, \mu })}_{\underbrace{(gv/2)^2}_{M_W^2} W^{+}_{\mu } W^{\mu, -}}
+ \frac{1}{2} \frac{v^2}{4}
\qty(- g A^{3}_{\mu } + g' B_{\mu })^2
\,.
\end{align}

So, we have found two massive \(W^{\pm}\) bosons, and the \textbf{combination} \(- g A^{3}_{\mu } + g' B_{\mu }\) has also gained mass.

Let us define \(\theta_{w}\), the Weinberg angle, by \(\tan \theta_{w} = g ' / g\).
Then we will have
%
\begin{align}
\cos \theta_{w} = \frac{g}{\sqrt{g^2 + g^{\prime 2}}}
\qquad \text{and} \qquad
\sin \theta_{w} = \frac{g'}{\sqrt{g^2 + g^{\prime 2}}}
\,,
\end{align}
%
and we define the electromagnetic field \(A_{\mu }\) and the \(Z_{\mu }\) boson by the two orthogonal combinations:
%
\begin{align}
A_{\mu } &= \sin \theta_{w} A^{3}_{\mu } + \cos \theta_{w} B_\mu \\
Z_{\mu } &= \cos \theta_{w} A^{3}_{\mu } - \sin \theta_{w} B_\mu
\,,
\end{align}
%
so that the kinetic term reads
%
\begin{align}
\frac{1}{2} \frac{v^2}{4} \qty(- g A^{3}_{\mu } + g' B_{\mu })^2
&= \frac{m_Z^2}{2} Z^{\mu }Z_{\mu }
\,,
\end{align}
%
where \(m_Z^2 = (g^2 + g^{\prime 2}) v^2/ 4 \), while there is no mass term for \(A\): so, \(m_A = 0\).

The residual gauge symmetry can be identified with \(U(1)_{\text{em}}\).
When the symmetry is broken, we are left with a long-range interaction and a short range one.

% Do note that \(U(1)\)-hypercharge \emph{is} broken.
% However, a certain combination of the generators gives us the \(U(1)\) electromagnetic.
The combination under which the vacuum is invariant is
%
\begin{align}
T^{3} + Y
\,,
\end{align}
%
where \(T^{3}\) is the third generator of \(SU(2)\), while \(Y\) is the generator of hypercharge.
This corresponds to
%
\begin{align}
\phi \to e^{i \vec{\alpha} \cdot \vec{\sigma} / 2} e^{i \beta /2} \phi
\,,
\end{align}
%
with \(\alpha^{3} = \beta \): this is due to the fact that
%
\begin{align}
\frac{1}{2} \qty(\sigma^{3} + \mathbb{1}) =  \left[\begin{array}{cc}
1 & 0 \\
0 & 0
\end{array}\right]
\,,
\end{align}
%
whose exponential leaves the second component of \(\phi = (0, v/\sqrt{2})\) invariant.

In summary, the SSB has the form
%
\begin{align}
SU(2)_L \times U(1)_{Y} \to U(1)_{\text{em}}
\,,
\end{align}
%
and it yields the two \(W^{\pm}\) bosons, each with mass \(gv/2\), and the \(Z\) boson with mass \(\sqrt{g^2+g^{\prime 2}} v/2\).
The masses of the \(W\) and \(Z\) bosons are related by:
%
\begin{align}
m_W = m_Z \cos \theta_{w}
\,,
\end{align}
%
so if we can devise some experiment which will measure \(\theta_{w}\) we can predict \(m_W / m_Z\).

The full expression of the covariant derivative reads, using the notation \(c_w = \cos \theta_{w}\), \(s_w = \sin \theta_{w}\) and \(\sigma^{\pm} = \qty(\sigma^{1} \mp i \sigma^{2}) / \sqrt{2}\):
\todo[inline]{not sure about the last one}
%
\begin{align}
\DD_{\mu } \Psi &= \qty[
    \partial_{\mu }
    -i \frac{g}{\sqrt{2}} \qty(W^{+}_{\mu } \sigma^{+}+ W^{-}\sigma^{-})
    - ig \qty(c_{w} Z_\mu + s_{w}A_{\mu }) I^{3}
    - ig \qty(- s_{w} Z_\mu + c_{w} A_{\mu }Y)
] \Psi  \\
&= \qty[\partial_{\mu }
    - i \frac{g}{\sqrt{2}} \qty(W^{+}_{\mu } \sigma^{+}+ W^{-}\sigma^{-})
    - i e A_{\mu }Q
    - i \frac{g}{c_w} Z_\mu Q_Z
] \Psi
\,,
\end{align}
%
where we defined \(e = g s_w = g' c_w \), and
%
\begin{align}
Q = I^{3} + Y
\qquad \text{and} \qquad
Q_Z = I^{3} - s_w^2 Q
\,.
\end{align}

\todo[inline]{The next bit is not super clear.}

If the mass of the fermion described by \(\Psi \) is zero we can decouple the left- and right-handed parts of the spinor.
We will get interactions between the left handed components, not between the right-handed components, since the \(W^{\pm}\) do not couple with them.
\todo[inline]{How does that come about exactly?}

We recover the \(V-A\) structure: the left- and right-handed spinors have different quantum numbers with respect to \(SU(2)_L\) and \(U(1)_Y\) but the same \(Q\), which is the quantum number corresponding to \(U(1)_{\text{em}}\).

The \(\psi_{L}\) are \(SU(2)_L\) \textbf{doublets}, with \(I = 1/2\); the \(\psi_{R}\) are \(SU(2)_L\) \textbf{singlets}, with \(I = 0\).

We then choose the values of the hypercharge such that the values of \(Q\) are compatible with experiment.

\begin{figure}[H]
\centering
\begin{tabular}{cccc}
Particle & \(I^{3}\) & \(Y\) & \(Q\)\\
\hline
\(\nu_{e, L}\) & \(+ 1 /2\) & \(- 1/2\)& \(0\) \\
\(\nu_{e, R}\) & \(0\) & \(0\)& \(0\) \\
\(e^-_{L}\) & \(- 1 /2\) & \(- 1/2\)& \(-1\) \\
\(e^-_{R}\) & \(0\) & \(-1\)& \(-1\) \\
\(u^-_{L}\) & \(+ 1 /2\) & \(1/6\)& \(2/3\) \\
\(u^-_{R}\) & \(0\) & \(2/3\)& \(2/3\) \\
\(d^-_{L}\) & \(-1 /2\) & \(1/6\)& \(-1/3\) \\
\(d^-_{R}\) & \(0\) & \(-1/3\)& \(-1/3\) \\
\end{tabular}
\label{tab:fermions-quantum-numbers}
\caption{Electroweak quantum numbers of the fermions.}
\end{figure}

% A combination which is broken is
% %
% \begin{align}
% Q_{z} = T^{3} - \sin^2 (\theta_{w}) Q
% \,,
% \end{align}
% %
% where \(\theta_{w}\) is the Weak, or Wonder angle, defined by
% %
% \begin{align}
% \tan(\theta_{w}) = \frac{g'}{g}
% \,,
% \end{align}
% %
% where \(g'\) and \(g\) are the coupling constants relative to \(U(1)\) and \(SU(2)\) respectively.

% The model is called the Glashow-Weinberg-Salam model. This is the Standard Model of the electroweak interaction.

% How is this unification since we have two coupling constants? The constants are not the coupling constants of weak and electromagnetic interaction. The photon is given by
% %
% \begin{align}
% A_{\mu } = \sin(\theta_{w}) A^{3}_{\mu } + \cos(\theta_{w}) B_{\mu }
% \,,
% \end{align}
% %
% while the orthogonal combination is
% %
% \begin{align}
% Z^{0}_{\mu } = \cos(\theta_{w}) A^{3}_{\mu } - \sin(\theta_{w}) B_{\mu }
% \,,
% \end{align}
% %
% so we cannot decouple the weak and electromagnetic bosons.
% This is why the symmetry is called the electroweak symmetry.

In terms of \(SU(2)_L\) multiplets, we separate:
%
\begin{align}
\left[\begin{array}{c}
\nu_{L} \\
e^{-}_{L}
\end{array}\right]
&&
e^{-}_{R}
&&
\left[\begin{array}{c}
u_L \\
d_L
\end{array}\right]
&&
u_R
&&
d_R
\,.
\end{align}

This is a \textbf{generation} (or family) of fermions: the ``electronic'' one, and we have two more: the muonic and tauonic ones.

\todo[inline]{Is this next bit useful?}
If \(\mu^2\) is a function of \(T\), then we can get a phase transition.
This is called the electroweak phase transition.

\end{document}


\section{Background}

\subsection{Basic Failure Model in Reliability Study}

In reliability study, the time when the first failure occurs in often assumed
to follow a probability density function (pdf) if time is a continuous value, or
a probability mass function (pmf) if time is a discrete value. \citep{MusaBook}

The value of time is a continuous value if its unit is a {\it time unit} (e.g.
second) and the value could be any real number.  The value of time is
a discrete value if its unit is a {\it natural unit} (e.g. number of
operations) or its unit is a {\it time unit} but the user only cares the
status of a system at discrete time (e.g. every second).

Although the precise definition of failure varies in different systems,
measures of failures can be consistently defined in terms of a pdf or a
pmf.  Assuming that the pdf of a system is $f(t)$, measures of failures can be
defined as in Figure \ref{eq:measure_of_failures}
\citep{MusaBook}.  Measures of failures can be defined in terms of pmf
similarly.

\begin{figure}
\begin{subequations}
\begin{align}
    R(t) & = \int_{t}^{\infty} f(x) dx = 1- \int_{0}^{t} f(x) dx  \label{subeq1}\\
   MTTF & = \int_{0}^{\infty} tf(t)dt  = \int_{0}^{\infty} R(t)dt
\label{mttf}\\
   h(t) & = \lim_{\Delta t\rightarrow 0} \frac{R(t)-R(t+\Delta t)}{\Delta t
R(t)}  = \frac{f(t)}{R(t)}
\end{align}
\end{subequations}
\caption{Measures of Failures}
\label{eq:measure_of_failures}
\end{figure}

In the above, the reliability during a specific time, $R(t)$, is the
probability that a system can survive without failure throughout that time.
The Mean Time to Failure (MTTF) is the average time when the first failure
occurs.  The hazard rate at time $t$ is the failure rate at that time given
the condition that the system has survived for $t$ time.  Equation
\ref{failure_check} checks that the average failure rate ($\lambda$) is the
reciprocal of MTTF.

\begin{equation}
 \lambda = \int_{0}^{\infty} h(t) dt = \int_{0}^{\infty} \frac{f(t)}{R(t)}  dt
=  \frac{\int_{0}^{\infty} f(t) dt}{\int_{0}^{\infty} R(t) dt} = \frac{1}{MTTF}
\label{failure_check}
\end{equation}

\subsection{Traditional Software Rejuvenation Models}

\subsubsection{The Basic Model}

The basic software rejuvenation model proposed by
\citep{huang1995software} is modelled by the state transition diagram in
Figure \ref{fig:model_classic_1}.  Huang et. al defines the following 4 states:

\begin{description}
  \item[S] The robust {\tt start} state in which the system will not fail.
  \item[W] The failure probable {\tt working} state in which the system may
fail at a certain probability.
  \item[F] The {\tt failure} state when the system reaches its boundary condition.
  \item[R] The {\tt rejuvenation} state when the system is plan to
restart to a clean state.
\end{description}

\citep{huang1995software} decides the rejuvenation thresholds using the
following process.

\begin{enumerate}
  \item compute the probabilistic {\it mean} rates of every state transitions
somehow.
  \item calculate the probability of the system being in each state, based on
the state transition rates computed above.
  \item calculate the {\it expected} total time of the system in state $s$
during an interval of $L$ time units as $T_s(L) = p_s \times L$, where $p_s$ is
the probability the system being in state $s$ calculated in the second step.
  \item calculate the cost of downtime during interval $L$ as $Cost(L) = (p_f
\times c_f + p_r \times c_r) \times L$, where $p_f$ and $p_r$ are probabilities
the system in state $F$ and $R$ respectively, and $c_f$ and $c_r$ are unit cost
of the system in state $F$ and $R$ respectively.
  \item determine the optimal rejuvenation thresholds by finding the optimal
transition rate between state $W$ to state $F$ so that the cost of downtime is
minimum.
\end{enumerate}

The original software rejuvenation model, proposed by
\citet{huang1995software}, has shown its significance in long running billing
systems, scientific applications, and telecommunication systems
\citep{huang1995software}. Readers may have noticed that the above estimation
methodology gives an approximate statistical estimation for a long running
system because the usage of {\it mean} state transition rates and the {\it
expected} time of being in each state.  By {\it long running system}, we refer
to a system whose expected in-service time is a statistically long time regards
to its MTTF, repair time, and rejuvenation time.

\begin{figure}
  \centering
        \subfigure[Traditional Model 1]{
            \label{fig:model_classic_1}
            \includegraphics[scale=0.5]{model_1.png}
        }\\
        \subfigure[Traditional Model 2]{
            \label{fig:model_classic_2}
            \includegraphics[scale=0.5]{model_2.png}
        }\\
    \caption{Traditional Software Rejuvenation Models}
   \label{fig:model_traditional}
\end{figure}

\subsubsection{A Modified Model}

\citet{dohi2000statistical} modifies the original model given
by \citet{huang1995software} with the following modifications:

\begin{enumerate}
  \item As shown in Figure \ref{fig:model_classic_2}, the completion of repair process
  is immediately followed by the software rejuvenation process.
  \item Assuming that every state transition is a stochastic processes.  For each state $S$, define a
  probability density function $F_s(t)$, which represents the probability that the system will stay in that
  state for time $t$.
\end{enumerate}

The first modification is made to distinguish the process of system cleanup and process resuming
from other repair tasks, the former of which is required in both the repair process and the rejuvenation
process in practice.  The second assumption is made so that the model is a Semi-Markov process,
a well studied stochastic process with off-the-shelf analysis techniques.  Although \citet{huang1995software}
do not mention the relationship between their model and Markov process, \citet{dohi2000statistical}
show that if the modified model gives the same analysis result as the one
given in \citet{huang1995software} if (i) remove assumption 1; and (ii) assume
that the sojourn times in all states are exponentially distributed.

\citet{dohi2000statistical} decides the optimal software rejuvenation thresholds by looking for
the one that maximise the system availability, the ratio of uptime and total time.  Same as the
methodology in \citet{huang1995software}, instead of precisely describe state transition
probabilities, $mean$ time of staying in the {\tt start} state, the {\tt failure} state, and the
{\tt rejuvenation} state is used.  The expected time of staying the failure probable {\tt working} state
is calculated by equation \ref{mttf}.

The methodology given in \citet{dohi2000statistical}  does not give a general cost
analysis as the one in \citet{huang1995software}.  It also suffers the problem of using
$mean$ times.  Despite those two limitations, \citet{dohi2000statistical}
derived a non-parametric statistical algorithms to estimate the optimal
software rejuvenation thresholds that maximise the system availability, based
on statistical complete sample data of failure times.

\begin{comment}
The basic assumption of software rejuvenation is that software systems will
become failure-probable after a period of execution.  In other words, failure
rate is a function about the execution time t.  In contrast, the probabilistic
state transition model
\url{
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.176.2557&rep=rep1&type=
pdf} (FTCS 1995, citation: 711) employs the statistical mean rate of the
transition rate between states.

   The same model is used in the book
\url{http://onlinelibrary.wiley.com/doi/10.1002/9780470050118.ecse394/full}
(published in 2007)

   The same problem appears in the model used in
\url{http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=897287} (HASE 2000,
citation: 60) and
\url{http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=895436} (PRDC 2000,
citation: 90), which extends the original model to be a semi-Markov process,
where time is a continuous value.

Models that use the statistical mean rate can only be used to estimate the
expected average behaviors (e.g. downtime) over a statistically long time.  A
more serious problem is that, treating failure rate as a constant in model
analysis violates the basic assumption of software rejuvenation.  After all, if
the failure rate is independent of the execution time, restarting the system
will not help at all but increase the downtime.

The link ( http://srejuv.ee.duke.edu/papers.htm ) gives a list of papers (until
2010) on software rejuvenation.  I am surprised that the classic general failure
model used in reliability analysis has not been applied to the model analysis of
software rejuvenation.
\end{comment}


\input{"/Users/brandonwilliams/Documents/LaTeX Includes/hwpreamble.tex"}
\input{"/Users/brandonwilliams/Documents/LaTeX Includes/extrapackages.tex"}
\input{"/Users/brandonwilliams/Documents/LaTeX Includes/extracommands.tex"}

\begin{document}

\title{\Large Classifying Spaces and Representability Theorems}
\author{\large Brandon Williams}

\maketitle

We will use the following notation for some common categories:
\begin{enumerate}
  \item[$\CW$] - The category of CW-complexes and continuous functions
  \item[$\hCW$] - The category of CW-complexes and homotopy classes of continuous functions
  \item[$\hCWp$] - The category of based CW-complexes and based homotopy classes of base point preserving continuous functions
  \item[$\Set$] - The category of sets and functions
  \item[$\Setp$] - The category of based sets and base point preserving functions
\end{enumerate}

\section{The Brown Representability Theorem}

A contravariant functor $F : \mathscr C \rightarrow \Set$ is said to be representable if there exists an object $X$ in $\mathscr C$ (called a classifying object) and a natural isomorphism
\[ \eta : \hom_{\mathscr C} (-, X) \longrightarrow F \]
Examples:
\begin{enumerate}
  \item Clearly $\hom(-,X)$ is a representable functor on any category $\mathscr C$.
  \item Singular cohomology $H^n(-;G)$ on $\hCW$ is representable since
  \[ H^n(X;G) \cong [X,K(G,n)] \]
  where $K(G,n)$ is the $n$-th Eilenberg-MacLane space of $G$.
  \item For a topological group $G$ let us define a functor $k_G : \hCWp \rightarrow \Setp$ by
  \[ k_G(X) = \lcb \text{isomorphism classes of principal $G$-bundles over $X$} \rcb \]
  For a morphism $X \stackrel{[f]}{\longrightarrow} Y$ the induced morphism $k_G([f]) : k_G(Y) \rightarrow k_G(X)$ is given by
  \[ k_G([f])(\xi) = f^* \xi \]
  As we will discuss later, it turns out that there is a space $BG$ such that
  \[ k_G(-) \simeq [-,(BG,*)] \]
\end{enumerate}
When $\mathscr C = \hCWp$ we have necessary and sufficient conditions for a contravariant functor $F : \hCWp \rightarrow \Setp$ to be representable. This is the content of the Brown Representability Theorem. Before stating the theorem, we define two properties the functor $F$ might have.

Let $\lcb X_\alpha \rcb$ be a collection of spaces, and let $i_\beta : X_\beta \rightarrow \vee_\alpha X_\alpha$ be the natural inclusions (recall that the coproduct in $\hCWp$ is the wedge construction, so these are the maps provided by the coproduct). We say that $F$ satisfies the wedge axiom if for any collection of spaces $\lcb X_\alpha \rcb$, the map $i : F(\vee_\alpha X_\alpha) \rightarrow \prod_\alpha F(X_\alpha)$ induced by the maps $F(i_\beta) : F(\vee_\alpha X_\alpha) \rightarrow F(X_\beta)$ is bijective.

Now let $(X;A,B)$ be a CW-triad, i.e. $A$ and $B$ are subcomplexes such that $X = A \cup B$. Let $j_A,j_B$ denote the inclusions of $A \cap B$ into the respective spaces, and let $i_A,i_B$ denote the inclusions of the respective spaces into $X$. Then we say that $F$ satisfies the Mayer-Vietoris axiom if for any CW-triad $(X;A,B)$ and for any $x \in F(A),y \in F(B)$ such that
\[ F(j_A)(x) = F(j_B)(y) \in F(A \cap B) \]
there exists an element $z \in F(X)$ such that
\[ F(i_A)(z) = x \ \ \ \ \ F(i_B)(z) = y \]
Notice that it is exactly this property that would allow us to conclude that $\image \subset \ker$ in the middle group of the Mayer-Vietoris sequence:
\[ \cdots \longleftarrow H^k(A \cap B) \longleftarrow H^k(A) \oplus H^k(B) \longleftarrow H^k(X) \longleftarrow \cdots \]

We can now state the Brown Representability Theorem:
\begin{lem}[Brown]
A contravariant functor $F : \hCWp \rightarrow \Setp$ is representable if and only if $F$ satisfies the wedge axiom and the Mayer-Vietoris axiom.
\end{lem}

The idea of the proof is to construct a CW-complex $(Y,y_0)$ and element $u \in F(Y)$ such that the natural transformation
\[ T_u : [ - , (Y,y_0)] \longrightarrow F(-) \]
\[ T_u(X)([f]) = F([f])(u) \]
is actually an equivalence. The necessity of F to satisfiy the wedge and Mayer-Vietoris axioms is easy enough to prove. First we recall some basic constructions. For based spaces $(X,x_0),(Y,y_0)$ the smash product is defined to be
\[ X \wedge Y = \frac{X \times Y}{X \vee Y} = \frac{X \times Y}{\lcb x_0 \rcb \times Y \cup X \times \lcb y_0 \rcb} \]
This is a based space by taking the base point to be the image of $X \vee Y$ under the quotient map. For an unbased space $X$ let $X^+$ denote $X$ union a disjoint point, which is then considered to be the base point of $X^+$. This seems to be a nice candidate for the product in the category of based spaces, but is not the product; the regular topological product is still the categorical product. However, the smash product is very useful due to the adjoint relation
\begin{equation}
\label{smashmapadjoint}
[(X \wedge Y,*),(Z,z_0)] \cong [(X,x_0), (Y,y_0)^{(Z,z_0)}]
\end{equation}
It is easy to see that $X \wedge I^+ \simeq (X \times I) / (\lcb x_0 \rcb \times I)$, so we see that a based homopty $H : X \times I \rightarrow Y$ between maps $X \rightarrow Y$ descends to a map $H : X \wedge I^+ \rightarrow Y$. Conversely, any based map $H : X \wedge I^+ \rightarrow Y$ is also a based homotopy when considered as a map $H : X \times I \rightarrow Y$.

\begin{lem}
The functor $[-,(Y,y_0)]$ satisfies the wedge axiom and the Mayer-Vietoris axiom.
\end{lem}
\begin{proof}
\sloppyspace
\begin{enumerate}

  \item[W.)] The maps $i_\beta^* : [\vee_\alpha X_\alpha] \rightarrow [X_\alpha,Y]$ induce a map $i : [\vee_\alpha X_\alpha] \rightarrow \prod_\alpha [X_\alpha,Y]$ as noted before. Let $\lcb [f_\alpha] \rcb \in \prod_\alpha [X_\alpha,Y]$, then we can fit the $f_\alpha$'s together to form a map $f : \vee_\alpha X_\alpha \rightarrow Y$ such that $f \circ i_\alpha = f_\alpha$. If we change an $f_\alpha$ by a homotopy, then $f$ also changes by a homotopy, hence we have $i([f]) = \lcb [f_\alpha] \rcb$, and so $i$ is surjective.

  Suppose $[f],[g] \in [\vee_\alpha X_\alpha,Y]$ such that $i([f]) = i([g])$. If we define $f_\alpha = f \circ i_\alpha$ and $g_\alpha = g \circ i_\alpha$, then we have $f_\alpha \simeq g_\alpha$, so let $H^\alpha : X_\alpha \wedge I^+ \rightarrow Y$ be the homotopies. These fit together to give us a map $H : \vee_\alpha (X_\alpha \wedge I^+) \rightarrow Y$ such that $H|_{X_\alpha \times 0} = f_\alpha$ and $H|_{X_\alpha \times 1} = g_\alpha$. But, since $\vee_\alpha (X_\alpha \wedge I^+) \cong (\vee_\alpha X_\alpha) \wedge I^+$, we have that $H$ is a map $(\vee_\alpha X_\alpha) \times I^+ \rightarrow Y$ such that $H_0 = f$ and $H_1 = g$, hence $[f] = [g]$, and so $i$ is injective.

  \item[MV.)] Let $(X;A,B)$ be a CW-triad, and let $[f] \in [(A,x_0),(Y,y_0)]$ and $[g] \in [(B,x_0),(Y,y_0)]$ such that $f|_{A \cap B} \simeq g|_{A \cap B}$. Let $\widetilde{H} : (A \cap B) \wedge I^+ \rightarrow Y$ be a homotopy between $f$ and $g$. Since $A \cap B \hookrightarrow A$ is a cofibration we can extend this homotopy to $H : A \wedge I^+ \rightarrow Y$ such that $H_0 = f$. Let $\widetilde{f} = H_1$, then we see that $[f]=[\widetilde{f}] \in [(A,a_0),(Y,y_0)]$, but now $\widetilde{f}|_{A \cap B} = g|_{A \cap B}$ (not just homotopic, but equal). Now we can easily extend this to a map $h : (X,x_0) \rightarrow (Y,y_0)$ such that $h|_A = \widetilde{f}$ and $h|_B = g$, and this verifies MV.
\end{enumerate}
\end{proof}

We will say that an element $u \in F(Y)$ is $n$-universal if $T_u(S^q) : [(S^q,*),(Y,y_0)] \rightarrow F(S^q)$ is an isomorphism for $q<n$ and an epimorphism for $q=n$ (recall that $T_u$ is the natural transformation defined earlier). This element is called universal if it is $n$-universal for all $n$.

\begin{thm}
\label{mapping-of-universal-elements}
If $f : (X,x_0) \rightarrow (Y,y_0)$ is a morphism in $\CWp$, and $u \in F(X),v \in F(Y)$ are universal elements such that $F(f)(v) = u$, then
\[ f_* : \pi_*(X,x_0) \longrightarrow \pi_*(Y,y_0) \]
is an isomorphism.
\end{thm}
\begin{proof}
We have the following commutative diagram:
\[
\xymatrix
{
\pi_q(X,x_0) = [(S^q,*),(X,x_0)] \ar[rr]^{f_*} \ar[rd]_{T_u(S^q)} & & [(S^q,*),(Y,y_0)] = \pi_q(Y,y_0) \ar[ld]^{T_v(S^q)} \\
& F(S^q)
}
\]
To see this let $[g] \in [(S^q,*),(X,x_0)]$, then $f_*([g]) = [f \circ g]$ and
\[ T_v(S^q)(f \circ g) = F(f \circ g)(v) = F(g) \circ F(f) (v) = F(g)(u) = T_u(S^q)(g) \]
By assumption we have $T_u(S^q)$ and $T_v(S^q)$ are bijective, so we must have that $f_*$ is bijective, hence it is an isomorphism.
\end{proof}

Most of the steps of the proof of the Brown Representability Theorem come from trying to construct universal elements, and the proofs of the lemmas that lead to such a construction are very similar to the proof of the Whitehead's theorem. We only state this theorem for now:

\begin{lem}
For any contravariant functor $F : \hCWp \rightarrow \Setp$ there exists a CW-complex $(Y,y_0)$ and universal element $u \in F(Y)$. In fact, with a choice of $(Y,y_0)$ and universal $u \in F(Y)$, the natural transformation $T_u : [-,(Y,y_0)] \rightarrow F$ is an equivalence.
\end{lem}

The following lemma is useful for when trying to make the construction of classifying spaces into a functorial construction.

\begin{lem}
\label{inducedmapclassifyingspaces}
Let $F,F' : \hCWp \rightarrow \Setp$ be two contravariant functors with classifying spaces $(Y,y_0),(Y',y'_0)$ and universal elements $u,u'$ respectively. If $T : F \rightarrow F'$ is a natural transformation, then there is a map $f : (Y,y_0) \rightarrow (Y',y'_0)$, unique up to homotopy, such that the diagram
\[
\xymatrix
{
  [(X,x_0),(Y,y_0)] \ar[r]^{f_*} \ar[d]_{T_u(X)} & [(X,x_0),(Y',y'_0)] \ar[d]^{T_{u'}(X)} \\
  F(X) \ar[r]_{T(X)} & F'(X)
}
\]
commutes for all $(X,x_0) \in \hCWp$.
\end{lem}

\begin{cor}
The classifying space of $F$ is unique up to homotopy equivalence.
\end{cor}
\begin{proof}
Suppose $F$ has two classifying spaces $(Y,y_0)$ and $(Y',y'_0)$ with universal elements $u,u'$ respectively. If we let $T : F \rightarrow F$ be the identity natural transformation, then \ref{inducedmapclassifyingspaces} gives us a map $f : (Y,y_0) \rightarrow (Y',y'_0)$ and commutative diagram (with $X = S^q$):
\[
\xymatrix
{
  \pi_q(Y,y_0) = [(S^q,*),(Y,y_0)] \ar[r]^{f_*} \ar[d]_{T_u(S^q)} & [(S^q,*),(Y',y'_0)] = \pi_q(Y',y'_0) \ar[d]^{T_{u'}(S^q)} \\
  F(S^q) \ar[r]_{T(S^q)=\id_{F(S^q)}} & F(S^q)
}
\]
Since $T_u(S^q)$ and $T_{u'}(S^q)$ are bijective (by the universality of $u$ and $u'$), we see that $f_*$ must be bijective, and hence an isomorphism. By Whitehead's theorem we have that $f$ is a homotopy equivalence.
\end{proof}

\section{Universal Bundles}

We now want to apply these ideas to the theory of vector bundles. Before we can do this we recall some basic facts from the theory of fiber bundles. Let $\xi : F \rightarrow E \stackrel{\pi}{\rightarrow} B$ be a fiber bundle with structural group $G \subset \Diff(F)$. Then we have an atlas $U_\alpha \subset B$, $\varphi_\alpha : U_\alpha \times F \stackrel{\sim}{\longrightarrow} \pi^{-1}(U_\alpha)$. This atlas determines transition functions:
\[ g_{\alpha\beta} : U_\alpha \cap U_\beta \rightarrow G \]
such that
\[ \psi_{\alpha\beta} := \varphi_\beta^{-1} \circ \varphi_\alpha : (U_\alpha \cap U_\beta) \times F \rightarrow (U_\alpha \cap U_\beta) \times F \]
\[ \psi_{\alpha\beta}(p,v) = (p, g_{\alpha\beta}(p)(v)) \]
If $G$ acts on another space $X$ on the left, then we can form the associated fiber bundle $\xi_X : X \rightarrow E' \rightarrow B$ from the data
\[ \widetilde{\psi}_{\alpha\beta} : (U_\alpha \cap U_\beta) \times X \rightarrow (U_\alpha \cap U_\beta) \times X \]
\[ \widetilde{\psi}_{\alpha\beta}(p,x) = (p,g_{\alpha\beta}(p) \cdot x) \]
In particular, $\xi_G$ is a principal $G$-bundle, called the associated principal $G$-bundle.

On the other hand, suppose $\xi : G \rightarrow E \stackrel{\pi}{\rightarrow} B$ is a principal $G$-bundle, and suppose $G$ acts on a space $X$ on the left. We can define an action of $G$ on $E \times X$ by:
\[ g \cdot (p,x) = (pg^{-1},gx) \]
Let $E \times_G X$ denote the quotient $(E \times X)/G$, and define $\pi_X : E \times_G X \rightarrow B$ by $\pi_X[p,x] = \pi(p)$. This makes a fiber bundle denoted by
\[ \xi[X] : X \rightarrow E \times_G X \rightarrow B \]
This is called the associated fiber bundle.

It turns out these two constructions are inverses of each other, as stated in the following two theorems:

\begin{thm}
Let $\xi : F \rightarrow E \rightarrow B$ be a fiber bundle in which the structural group $G$ acts freely and transitively on $F$, then
\[ \xi \cong \xi_G[F], \]
that is the associated fiber bundle of the associated principal $G$-bundle is equivalent to the original fiber bundle.
\end{thm}

\begin{thm}
Let $\xi : G \rightarrow E \rightarrow B$ be a principal $G$-bundle and $X$ a space on which $G$ acts freely and transitively. Then
\[ \xi \cong \xi[X]_G, \]
that is the associated principal $G$-bundle of the associated fiber bundle is equivalent to the original principal $G$-bundle.
\end{thm}

These theorems allow us to reduce the classification of (real, complex, quaternionic) vector bundles over a space to the classification of principal ($\GL(n),\U(n),\Sp(n)$)-bundles.

For a topological group $G$ let us define a contravariant functor $k_G : \hCWp \rightarrow \Setp$ by
\[ k_G(X) = \lcb \text{isomorphism classes of principal $G$-bundles over $X$} \rcb \]
For $X \stackrel{[f]}{\longrightarrow} Y$ we define $k_G([f]) : k_G(Y) \rightarrow k_G(X)$ by
\[ k_G([f])(\xi) = f^*\xi \]
This function is well-defined by the fact that pullbacks of bundles under homotopic maps are equivalent. The base point of $k_G(X)$ is the equivalence class of the trivial $G$-bundle $G \rightarrow G \times X \rightarrow X$.

\begin{thm}
The functor $k_G$ satisfies the wedge axiom and the Mayer-Vietoris axiom.
\end{thm}

Therefore to each topological group $G$ there is a CW-complex $BG$ (determined up to homotopy type) and a principal $G$-bundle $G \rightarrow EG \rightarrow BG$ (this is the universal element) such that the natural transformation
\[ T_G : [-,(BG,*)] \rightarrow k_G(-) \]
defined by $T_G(X)([f]) = \lcb f^*EG \rcb$ is an equivalence. Therefore principal $G$-bundles are classified by homotopy classes of maps into $BG$. For this reason we call $BG$ the classifying space of $G$ and $EG \rightarrow BG$ the universal bundle of $G$. All principal $G$-bundles are pullbacks of the universal bundle. The classifying spaces $\BO(n)$, $\BU(n)$ and $\BSp(n)$ are very important in $K$-theory, and we can easily find explicit constructions of these spaces (not done here). One form of the Bott periodicity theorem in $K$-theory can be stated as
\[ \mathbb Z \times \BU  \simeq \Omega^2 \BU  \]
\[ \mathbb Z \times \BO  \simeq \Omega^4 \BSp \]
\[ \mathbb Z \times \BSp \simeq \Omega^4 \BO  \]

Let us now see how $B-$ can be turned into a functor. For now we will think of $B-$ as a functor from $\TopGrp$, the category of topological groups and continuous homomorphisms (these spaces are automatically based at the identity and homomorphisms preserve this point), to $\hCWp$. Clearly $B-$ will take a topological group $G$ to its classifying space $BG$. If $h : G \rightarrow G'$ is a morphism of topological groups, then we can define a natural transformation $T : k_G \rightarrow k_{G'}$ is the following way. Give a space $X$ and a principal $G$-bundle $\xi$ over $X$ with transition functions $\lcb g_{\alpha\beta} \rcb$, let $T(X)(\xi)$ be the principal $G'$-bundle over $X$ given by transition functions $\lcb h \circ g_{\alpha\beta} \rcb$. Then \ref{inducedmapclassifyingspaces} gives us an induced map $(BG,*) \rightarrow (BG',*)$, which we call $Bh$.

Now let us apply this machinery to the case of $G$-bundles over the suspension, $\Sigma X$, of a space $X$. Here we are taking the reduced suspension $\Sigma X = X \wedge S^1$. By the adjoint relation \eqref{smashmapadjoint} we see that principal $G$-bundles over $\Sigma X$ are in one-to-one correspondence with
\[ [(\Sigma X,*),(BG,*)] \cong [(X,*),(\Omega BG,*)] \]
We can write $\Sigma X$ as the union of two contractible pieces that intersect in a space that deformation retracts onto $X$:
\[ CX^+ = \lcb [x,t] \in \Sigma X \st t \in (1/4,1] \rcb \ \ \ \ \ \ CX^- = \lcb [x,t] \in \Sigma X \st t \in [0,3/4) \rcb \]
\[ CX^+ \cap CX^- = \lcb [x,t] \in \Sigma X \st t \in (1/4,3/4) \rcb \simeq X \]
Therefore every $G$-bundle over $\Sigma X$ can be constructed from a map $CX^+ \cap CX^- \rightarrow G$. For a map $f : X \rightarrow G$ let us define $\widetilde{f} : CX^+ \cap CX^- \rightarrow G$ by $\widetilde{f}[x,t] = f(x)$, and let $\xi(f)$ denote the $G$-bundle constructed via $\widetilde{f}$.
\begin{lem}
Two maps $f_0,f_1 : (X,x_0) \rightarrow (G,1)$ are homotopic rel $x_0$ if and only if $\xi(f_0) = \xi(f_1)$.
\end{lem}
This lemma tells us that the natural transformation
\begin{equation}
\label{suspension-classifying-natural-equivalent}
T : [-,(G,1)] \rightarrow k_G \circ \Sigma
\end{equation}
is injective. It can also be shown that $T$ is actually a natural equivalence, hence principal $G$-bundles over $\Sigma X$ are classified by homotopy classes of maps of $X$ into $G$.
\begin{cor}
$G$ is homotopy equivalent to $\Omega BG$.
\end{cor}
\begin{proof}
We have the following sequence of naturally equivalent functors
\[ [-,\Omega BG] \longrightarrow [\Sigma-,BG] \longrightarrow k_G \circ \Sigma(-) \]
Since naturally equivalent functors have homotopy equivalent classifying spaces we see that $\Omega BG$ is the classifying object of $k_G \circ \Sigma$. The natural equivalence of \eqref{suspension-classifying-natural-equivalent} now shows that $\Omega BG$ is homotopy equivalent to $G$.
\end{proof}
So we can think of $B-$ as a one-sided inverse to $\Omega$ when applied to certain spaces. By the adjoint relation \eqref{smashmapadjoint} we have
\[ \pi_n(G) \cong \pi_n(\Omega BG) \cong \pi_{n+1}(BG) \]
In particular, if $G$ is discrete, then
\[ \pi_n(BG) \cong \pi_{n-1}(G) = \begin{cases} G & n=1 \\ 0 & n>1 \end{cases} \]
hence $BG$ is a $K(G,1)$ space.

\begin{lem}
For any topological group $G$, the total space $EG$ of the universal bundle is weakly contractible.
\end{lem}
\begin{proof}
\end{proof}

\section{Examples}

Here we will construct the universal bundles for some topological groups. Let us take the simplest non-trivial topological group, $G = S^1 = U(1)$. Then $BU(1)$ is a space such that $\pi_n(BU(1)) \cong \pi_{n-1}(G)$, so $BU(1)$ must be a $K(\mathbb Z,2)$ space. This space must be homotopy equivalent to $\mathbb CP^\infty$, infinite complex projective space.

\end{document}


\documentclass[DM,lsstdraft, authoryear,toc]{lsstdoc}
% lsstdoc documentation: https://lsst-texmf.lsst.io/lsstdoc.html
\input{meta}

% Package imports go here.
\usepackage{amsmath}
\usepackage{amssymb}
% Local commands go here.
\newcommand{\rmd}{\mathrm{d}^2}
%If you want glossaries
%\input{aglossary.tex}
%\makeglossaries

\title{Gaussian-Aperture and PSF photometry}

% Optional subtitle
% \setDocSubtitle{A subtitle}

\author{%
Arun Kannawadi
}

\setDocRef{DMTN-190}
\setDocUpstreamLocation{\url{https://github.com/lsst-dm/dmtn-190}}

\date{\vcsDate}

% Optional: name of the document's curator
% \setDocCurator{The Curator of this Document}

\setDocAbstract{%
Rubin Science Pipelines of the Gaussian-Aperture and PSF photometry algorithm for consistent galaxy colors
}

% Change history defined here.
% Order: oldest first.
% Fields: VERSION, DATE, DESCRIPTION, OWNER NAME.
% See LPM-51 for version number policy.
\setDocChangeRecord{%
  \addtohist{1}{YYYY-MM-DD}{Unreleased.}{Arun Kannawadi}
}

\begin{document}

% Create the title page.
\maketitle
% Frequently for a technote we do not want a title page  uncomment this to remove the title page and changelog.
% use \mkshorttitle to remove the extra pages

% ADD CONTENT HERE
% You can also use the \input command to include several content files.
\section{Notation}
\begin{itemize}
    \item $g({\bf x})$: unobservable pre-seeing galaxy profile
    \item $G({\bf x})$: observable image of galaxy with a Gaussian PSF
    \item $I({\bf x})$: observed image of the galaxy with some PSF
    \item $K({\bf x})$: convolution kernel that converts $I({\bf x})$ to $G({\bf x})$, with a desired Gaussian PSF.
\end{itemize}

\section{GAaP flux}
Based on Eq. A16 of \cite{Kuijken2015}, the GAaP flux with an aperture parameter ${\bf W}$ is defined as follows:
\begin{align}
  F_{\bf W} &\equiv \int\rmd{\bf x}\, g({\bf x})\exp\left( -\frac{1}{2}{\bf x}^T{\bf W}^{-1}{\bf x} \right) \\
        &= \frac{1}{2}\frac{\det({\bf W})^{1/2}}{\det({\bf W}-p^2{\bf 1})^{1/2}}\times 2\int\rmd{\bf x} G(\bf x) \exp\left(-\frac{1}{2}{\bf x}^T({\bf W}-p^2{\bf 1})^{-1}{\bf x}\right),
  \label{eq:A16}
\end{align}
where $G({\bf x})$ is the image of $g({\bf x})$ after convolution by a Gaussian PSF of size $p$.
The integral is computed using \texttt{computeFixedMomentsFlux}\footnote{
  Note: \texttt{computeFixedMomentsFlux} computes the flux of an image $I({\bf x})$ weighted by an aperture ${\bf Q}$ as $2\int\rmd{\bf x}\, I({\bf x})\exp\left(-\frac{1}{2} {\bf x}^T {\bf Q}^{-1}{\bf x}\right)$, with a factor 2 in the normalization. This is such that if $I({\bf x})$ is a Gaussian with shape ${\bf Q}$ and has a total flux $F$, the integral evaluates to $F$.}
  by passing the PSF-Gaussianize image and shape parameter $({\bf W}-p^2{\bf 1})$.
The factor multiplying the integral, especially $\det({\bf W}-p^2{\bf 1})^{1/2}$, is required to keep $F_{\bf W}$ PSF-independent.
We refer to this factor, the square root of the ratio of determinants, as \texttt{fluxScaling}. We scale the \texttt{instFlux} value from the \texttt{computeFixedMomentsFlux} method with \texttt{fluxScaling}.

For circular apertures, $\texttt{fluxScaling} = \frac{1}{2}\frac{\sigma_w^2}{\sigma_w^2-p^2}$,
where ${\bf W} = \sigma_w^2 \bf{1}$. In the GAaP plugin, $\sigma_w$ values are specified in the \texttt{sigmas} config parameter..

\section{Propagating noise covariance}
Let us calculate the covariance $C^G$ between the errors on two pixel values $G({\bf x})$ and $G({\bf y})$. Rewriting Eq. A9 of \cite{Kuijken2015}, we get
\begin{equation}
  Cov(G({\bf x}), G({\bf y})) = \int\int\rmd{\bf x}'\rmd{\bf y}'\, Cov(I({\bf x}'),I({\bf y}'))\, K({\bf x}-{\bf x}')K({\bf y}-{\bf y}')
\end{equation}

In KiDS papers, including \cite{Kuijken2015}, translational invariance is assumed and $Cov(I({\bf x}'),I({\bf y}'))$ is expressed as a function of $({\bf x}'-{\bf y}')$ alone and an appropriate covariance matrix is constructed empirically.

However, in Rubin science pipelines, because we keep track of only the variance , our model for $Cov(I({\bf x}'), I({\bf y}')) = \sigma^2({\bf x}')\delta_D({\bf x'}-{\bf y}')$, where $\sigma^2({\bf x}')$ is given by the variance plane. This is incorrect strictly speaking, as the noise \emph{is} correlated on the coadds. However, we proceed with the information we have available. Substituting this in the above equation, we get
\begin{equation}
  Cov(G({\bf x}), G({\bf y})) = \int\rmd{\bf x}'\, \sigma^2({\bf x}') K({\bf x}-{\bf x}')K({\bf y}-{\bf x}')
\end{equation}

The kernel $K$ is expected to be compact, and if the variance plane is slowly varying, we can approximate $\sigma^2({\bf x}')$ by the variance value at the centroid of the source, say $\sigma^2$. This approximation is further justified because of Gaussian weighting we will employ in Eq.~\ref{eq:A17}, which makes the effective kernel even more compact. Redefining ${\bf x}' \rightarrow {\bf x} - {\bf x}'$ ($\rmd{\bf x}' \rightarrow \rmd{\bf x}'$ because the dimensionality is even), we get
\begin{equation}
  Cov(G({\bf x}), G({\bf y})) \approx \sigma^2 \xi_K({\bf r}) \equiv C^G({\bf r}),
\end{equation}
where ${\bf r} = {\bf y}-{\bf x}$. Thus, the covariance is the auto-correlation function of the kernel $K$ $\xi_K({\bf r}) \equiv \int\rmd{\bf x}\, K({\bf x})K({\bf x}+{\bf r})$  scaled by the variance $\sigma^2$ at the location of the source. The auto-correlation function is computed by the \texttt{\_computeKernelAcf} static method.

\section{Estimating uncertainties}
Eq. A17 of~\cite{Kuijken2015} says
\begin{equation}
    \text{Var}(F_{\bf W}) = \frac{\det({\bf W})}{\det({\bf W}-p^2\bf{1})} \pi \det({\bf W}-p^2{\bf 1})^{1/2} \int\rmd {\bf x}\, C^G({\bf x}) \exp\left(-\frac{1}{4}{\bf x}^T({\bf W}-p^2{\bf 1})^{-1}{\bf x}\right).
    \label{eq:A17}
\end{equation}
Note the missing factor of $2^{1/2}$, which is an error in \cite{Kuijken2015}.
Since we represent
\begin{equation}
    C^G({\bf r}) = \sigma^2 \xi_{K}({\bf r}),
\end{equation}
we get
\begin{equation}
  \text{Var}(F_{\bf W}) = \frac{\det({\bf W})}{\det({\bf W}-p^2\bf{1})}\left(\frac{1}{2}\right)^2 \times 4\pi \sigma^2 \det({\bf W}-p^2{\bf 1})^{1/2} \times \int\rmd {\bf r}\, \xi_{K}({\bf r}) \exp\left(-\frac{1}{2}{\bf r}^T(2({\bf W}-p^2{\bf 1}))^{-1}{\bf r}\right).
\end{equation}
We categorize them into three terms, separated by $\times$.
\begin{enumerate}
  \item The naive calculation of flux variance by \texttt{computeFixedMomentsFlux} yields the middle term $4\pi \sigma^2 \det({\bf W}-p^2{\bf 1})^{1/2}$ (given by \texttt{instFluxErr}$^2$).
  \item The factor $\frac{1}{4}\frac{\det({\bf W})}{\det({\bf W}-p^2\bf{1})}$ appears because of the scaling factor in $F_{\bf W}$ (Eq. A16 of \cite{Kuijken2015}).
  \item The square root of the integral is computed by \texttt{\_getFluxErrScaling} and referred to as \texttt{fluxErrScaling}. This is the actual contribution due to correlations in the noise introduced by PSF-Gaussianization procedure. This is computed using \texttt{computeFixedMomentsFlux} on the auto-correlation function, with $2 \times$ the shape parameter of aperture used to measure $F_{\bf W}$.

  If the PSF had been Gaussian to begin with, or if we were neglecting the effects of correlated noise on flux uncertainties, $K({\bf r}) = \delta_D({\bf r})$. This leads to the integral evaluating to 1.
\end{enumerate}

Note that from the definition of $\xi_K({\bf r})$, it follows that
\begin{align}
  \int\rmd{\bf r}\, \xi_K({\bf r}) &= \int\rmd{\bf r}\, \int\rmd{\bf x}\, K({\bf x})K({\bf x}+{\bf r})\\
                                   &= \int\rmd{\bf x}\, K({\bf x}) \int\rmd{\bf r}\, K({\bf x}+{\bf r})\\
                                   &= \left[ \int\rmd{\bf x}\, K({\bf x})\right]^2
                                   \label{eq:integral_acf}
\end{align}

In a similar manner, the integral for \texttt{fluxErrScaling} can also be expressed as
\begin{equation}
  \int\rmd {\bf r}\, \xi_{K}({\bf r}) \exp\left(-\frac{1}{2}{\bf r}^T(2({\bf W}-p^2{\bf 1}))^{-1}{\bf r}\right) =
  \left[ \int\rmd{\bf x}\int\rmd{\bf y} K({\bf x}-{\bf y}) \exp\left(-\frac{1}{2}{\bf y}^T({\bf W}-p^2{\bf 1})^{-1}{\bf y}\right)\right]^2.
\end{equation}
The proof follows by considering $\int\rmd{\bf x} f({\bf x}) = \tilde{f}(0)$, where $\tilde{f}$ is the Fourier transform of $f$.

\subsection{Special case of Gaussian kernels}
Suppose $I({\bf x})$ has a circular Gaussian PSF of size $s$ and the target PSF is a Gaussian PSF of size $p = fs$ ($f>1$), then the kernel $K$ is also a Gaussian of size $s(f^2-1)^{1/2}$.
In the GAaP plugin, the values for $f$ are given by \texttt{scalingFactors}.

Since flux-conservation implies $\int\rmd{\bf x}\, K({\bf x}) = 1$, we can immediately write
\begin{equation}
  K({\bf x}) = \frac{1}{2\pi (f^2-1)s^2} \exp\left(-\frac{{\bf x}^T{\bf x}}{2(f^2-1)s^2}\right)
\end{equation}

The auto-correlation function $\xi_K({\bf r})$ is then given by
\begin{equation}
  \xi_K({\bf r}) = \frac{1}{4\pi(f^2-1)s^2}\exp\left(-\frac{{\bf r}^T{\bf r}}{4(f^2-1)s^2}\right).
\end{equation}
This is easy to see by first recognizing that $\xi_K({\bf r})$ must be a Gaussian with size $\sqrt{2}$ times larger than that of $K$ and the normalization factor follows that $\xi_K({\bf r})$ must integrate to 1 if $K$ integrates to 1 (see Eq.~\ref{eq:integral_acf}).

The square of the \texttt{fluxErrScaling} parameter is then given by the Gaussian integral
\begin{equation*}
  \int\rmd{\bf r}\,\xi_K({\bf r})\exp(-\frac{{\bf r}^T{\bf r}}{4(\sigma^2-p^2)}),
\end{equation*}
where $\sigma$ is the size of the Gaussian aperture for the pre-seeing source $g({\bf x})$. In the GAaP plugin, these values are given by \texttt{sigmas} config parameter.

The exponents of the Gaussians is simplified as follows.
\begin{equation}
  \frac{{-\bf r}^T{\bf r}}{4}\left(\frac{1}{(f^2-1)s^2} + \frac{1}{(\sigma^2-f^2s^2)} \right)
  = \frac{{-\bf r}^T{\bf r}}{4}\left( \frac{\sigma^2 - s^2}{s^2(f^2-1)(\sigma^2-f^2s^2)} \right)
\end{equation},
where $p$ is replaced by $fs$. Evaluating the Gaussian integral, we get
\begin{align}
  \texttt{fluxErrScaling}^2 &= \frac{1}{4\pi (f^2-1)s^2} \times \frac{\pi 4s^2(f^2-1)(\sigma^2-f^2s^2)}{\sigma^2-s^2} \\
  &= \frac{\sigma^2-f^2s^2}{\sigma^2-s^2}
\end{align}
As a consistency check, we get $\texttt{fluxErrScaling} = 1$ for $f=1$, i.e., if we do not carry out the PSF-Gaussianization procedure. For $f>1$, $\texttt{fluxErrScaling} < 1$. As an aside, if $\xi_K({\bf r}) \ge 0$ for all ${\bf r}$ (as in the Gaussian kernel case), \texttt{fluxErrScaling} is guaranteed to be less than 1. In other words, the naive flux uncertainty overestimates the true uncertainty. For naive errors to be an underestimation of true errors, it is necessary that the kernel should be negative for sufficiently small $|{\bf r}|$. Intuitively, this makes sense; non-negative valued kernel smoothes the noise in the image, reducing its power, whereas as kernel with both positive and negative values has the potential to amplify the random fluctuations in different pixels.

\appendix
% Include all the relevant bib files.
% https://lsst-texmf.lsst.io/lsstdoc.html#bibliographies
\section{References} \label{sec:bib}
\renewcommand{\refname}{} % Suppress default Bibliography section
\bibliography{local,lsst,lsst-dm,refs_ads,refs,books}

% Make sure lsst-texmf/bin/generateAcronyms.py is in your path
\section{Acronyms} \label{sec:acronyms}
\input{acronyms.tex}
% If you want glossary uncomment below -- comment out the two lines above
%\printglossaries

\end{document}


\appendix
\section{Supplemental Materials}

\begin{table}[htbp]
	\centering
	\resizebox{0.8\linewidth}{!}{%
		\begin{tabular}{crrr}
			\toprule
			\textbf{Model} & \textbf{Learning rate} & \textbf{Max\_depth} & \textbf{n\_estimators}  \\ \midrule
			 GradientBoostingRegressor & 0.03      & 6   &  500        \\
			 XGBoostRegressor & 0.1      & 3   & 100     \\
			 CatBoostRegressor    & 0.1      & 3   & 100     \\ \bottomrule
		\end{tabular}
	}
	\caption{Default model parameters}
	\label{tab:default-parameters}
\end{table}

\begin{table}[htbp]
	\centering
	\resizebox{0.45\linewidth}{!}{%
		\begin{tabular}{lr}
			\toprule
			\textbf{Parameter} & \textbf{Parameter values} \\
			\midrule
			Learning rate & [0.1, 0.05, 0.01] \\
			Max estimator depth & [1, 2, 3, 6] \\
			Number of estimators & [100, 500, 1000] \\
			\bottomrule
		\end{tabular}
	}
	\caption{Grid search parameters}
	\label{tab:grid-search-parameters}
\end{table}