\section{The Secretary Problem}

\definition{The secretary problem}
Say we need to hire a secretary. We have exactly one position to fill,
and we must fill it with one of $n$ applicants. These $n$ applicants,
if put together, can be ranked unambiguously from \say{best} to \say{worst}.

\vspace{2mm}

We interview applicants in a random order, one at a time. \par
At the end of each interview, we either reject the applicant (and move on to the next one), \par
or select the applicant (which fills the position and ends the process).

\vspace{2mm}

Each applicant is interviewed at most once---we cannot return to an applicant we've rejected. \par
In addition, we cannot reject the final applicant, as doing so will leave us without a secretary.

\vspace{2mm}

For a given $n$, we would like to maximize our probability of selecting the best applicant. \par
This is the only metric we care about---we do not try to maximize the rank of our applicant. \par
Hiring the second-best applicant is no better than hiring the worst.

\problem{}
If $n = 1$, what is the best hiring strategy, and what is the probability that we hire the best applicant?

\begin{solution}
	This is trivial. Hire the first applicant, she's always the best.
\end{solution}

\vfill




\problem{}
If $n = 2$, what is the best hiring strategy, and what is the probability that we hire the best applicant? \par
Is this different than the probability of hiring the best applicant at random?

\begin{solution}
	There are two strategies:
	\begin{itemize}
		\item hire the first
		\item hire the second
	\end{itemize}

	Both are equivalent to the random strategy.

	\vspace{2mm}

	Intuitively, the fact that a strategy can't help us makes sense: \par
	When we're looking at the first applicant, we have no information; \par
	when we're looking at the second, we have no agency (i.e, we \textit{must} hire).
\end{solution}


\vfill


\problem{}
If $n = 3$, what is the probability of hiring the best applicant at random? \par
Come up with a strategy that produces better odds.

\begin{solution}
	Once we have three applicants, we can make progress.

	\vspace{2mm}

	The remark from the previous solution still holds: \par
	When we're looking at the first applicant, we have no information; \par
	when we're looking at the second, we have no choices.

	\vspace{2mm}

	So, let's make our decision at the second candidate. \par
	If we hire only when the second candidate is better than the first, \par
	we end up hiring the best candidate exactly half the time.

	\vspace{2mm}

	This can be verified by checking all six cases.
\end{solution}

\vfill
\pagebreak

%
% MARK: Page
%


\problem{}<bestyet>
Should we ever consider hiring a candidate that \textit{isn't} the best we've seen so far? \par
Why or why not? \hint{Read the problem again.}

\begin{solution}
	No! A candidate that isn't the best yet cannot be the best overall! \par
	Remember---this problem is only interested in hiring the \textit{absolute best} candidate. \par
	Our reward is zero in all other cases.
\end{solution}

\vfill


\remark{}
\ref{bestyet} implies that we should automatically reject any applicant that isn't
the best we've seen. We can take advantage of this fact to restrict the types of
strategies we consider.

\remark{}
Let $B_x$ be the event \say{the $x^\text{th}$ applicant is better than all previous applicants,} \par
and recall that we only know the \textit{relative} ranks of our applicants: \par
given two candidates, we know \textit{which} is better, but not \textit{by how much}.

\vspace{2mm}

Therefore, the results of past events cannot provide information about future $B_x$. \par
All events $B_x$ are independent.

\vspace{2mm}

We can therefore ignore any strategy that depends on the outcomes of individual $B_x$.
Given this realization, we are left with only one kind of strategy: \par
We blindly reject the first $(k - 1)$ applicants, then select the next \say{best-yet} applicant. \par
All we need to do now is pick the optimal $k$.

\problem{}
Consider the secretary problem with a given $n$. \par
What are the probabilities of each $B_x$?

\vfill



\problem{}<seca>
What is the probability that the $n^\text{th}$ applicant is the overall best applicant?

\begin{solution}
	All positions are equally likely. $\nicefrac{1}{n}$.
\end{solution}

\vfill
\pagebreak

%
% MARK: Page
%




\problem{}<secb>
Given that the $x^\textit{th}$ applicant is the overall best, what is the probability of hiring this applicant \par
if we use the \say{look-then-leap} strategy detailed above? \par
\hint{
	Under what conditions would we \textit{not} hire this applicant? \par
	This probability depends on $k$ and $x$.
}

\begin{solution}
	Say that the $x^\text{th}$ applicant is the best overall. If we do not hire this applicant,
	we must have hired a candidate that came before them. \par

	\vspace{2mm}

	What is the probability of this? We saw $x-1$ applicants before the $x^\text{th}$. \par
	If we hired one of them, the best of those initial $x-1$ candidates did \textit{not} fall
	into the initial $k-1$ applicants we rejected.
	\note{(This is again verified by contradiction: if the best of the first $x-1$ applicants
	\textit{was} within the first $k-1$, we would hire the $x^\text{th}$)}

	\vspace{2mm}

	There are $x-1$ positions to place the best of the first $x-1$ candidates, \par
	and $k-1$ of these positions are initially rejected. \par
	Thus, the probability of the best of the first $x-1$ applicants being rejected is $\frac{k-1}{x-1}$.

	\vspace{2mm}

	Unraveling our previous logic, we find that the probability we are interested in is also $\frac{k-1}{x-1}$.
\end{solution}

\vfill

\problem{}<phisubn>
Consider the secretary problem with $n$ applicants. \par
If we reject the first $k$ applicants and hire the first \say{best-yet} applicant we encounter, \par
what is the probability that we select the best candidate? \par
Call this probability $\phi_n(k)$.

\begin{solution}
	Using \ref{seca} and \ref{secb}, this is straightfoward:
	\[
		\phi_n(k)
		= \sum_{x = k}^{n}\left( \frac{1}{n} \times \frac{k-1}{x-1} \right)
	\]
\end{solution}

\vfill

\problem{}
Find the $k$ that maximizes $\phi_n(k)$ for $n$ in $\{1, 2, 3, 4, 5\}$.

\begin{solution}
	Brute force. We already know that $\phi_1(1) = 1.0$ and $\phi_2(1) = \phi_3(2) = 0.5$. \par
	The maximal value of $\phi_4$ is $\phi_4(2) = 0.46$, and of $\phi_5$ is $\phi_5(3) = 0.43$.
\end{solution}

\vfill
\pagebreak


%
% MARK: Page
%

\problem{}
Let $r = \frac{k-1}{n}$, the fraction of applicants we reject. Show that
\begin{equation*}
	\phi_n(k)
	= r \sum_{x = k}^{n}\left( \frac{1}{x-1} \right)
\end{equation*}

\begin{solution}
	This is easy.
\end{solution}

\vfill

\problem{}
With a bit of faily unpleasant calculus, we can show that
\begin{equation*}
	\underset{n \rightarrow \infty}{\text{lim}}
	\sum_{x=k}^{n}\frac{1}{x-1}
	~\approx~ \text{ln}\Bigl(\frac{n}{k}\Bigr)
\end{equation*}
Use this fact to find $\underset{n \rightarrow \infty}{\text{lim}} \phi_n(k)$.~
\hint{For large $n$, $\frac{k-1}{n} \approx \frac{k}{n}$.}

\begin{solution}
	\begin{equation*}
		\underset{n \rightarrow \infty}{\text{lim}} \phi_n(k)
		~=~ \underset{n \rightarrow \infty}{\text{lim}}
			\Biggl( r \sum_{x = k}^{n}\left( \frac{1}{x-1} \right) \Biggr)
		~\approx~ r \times \text{ln}\left(\frac{n}{k}\right)
		~=~ -r \times \text{ln}\left(\frac{k}{n}\right)
		~\approx~ -r \times \text{ln}(r)
	\end{equation*}
\end{solution}

\vfill

\problem{}
Find the $k$ that maximizes $\underset{n \rightarrow \infty}{\text{lim}} \phi_n(k)$. \par
Also, find the value of $\phi_n$ at this point. \par
\note{If you aren't familiar with calculus, ask an instructor for help.}


\begin{solution}
	Use the usual calculus tricks:
	\begin{equation*}
		\frac{d}{dr} \bigl( -r \times \text{ln}(r) \bigr)
		= -1 - \text{ln}(r)
	\end{equation*}

	Which is zero at $r = e^{-1}$. The value of $ -r \times \text{ln}(r)$ at this point is also $\frac{1}{e}$.
\end{solution}


\vfill

Following this strategy, we should thus expect to select the best candidate about $e^{-1} = 37\%$ of the time,
\textit{regardless of $n$.} Our probability of success does not change as $n$ gets larger! \par
\note{Recall that the random strategy succeeds with probability $\nicefrac{1}{n}$. \par
That is, it quickly becomes small as $n$ gets large.}

\pagebreak
