\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{float}
\usepackage{amssymb,amsmath}
\usepackage[colorlinks,linkcolor=blue,urlcolor=blue,citecolor=black]{hyperref} % Create hyperlinks within the document
\usepackage{url}

%homework
%\long\def\comment#1{}
%solution 
\long\def\comment{}

\newcommand{\lit}[1]{\fbox{\texttt{#1}}}

\begin{document}

\title{{\bf CSXXX: NLP/Text Mining for Security}\\
       Homework Assignment \#1:\\
       Introduction \& Mathematical
       Foundations }

\author{}

\date{Out: Month date, Year\\
      Due: Month date, Year\\
      (Some materials need to be turned-in)}
\maketitle

\section{Conditional probability Problem} \label{problem1}
A student is planning to take the
first three examinations in the coming summer. She will take the first exam in June. If she passes that exam,
then she will take the second exam in July, and if she also passes the second
one, then she will take the third exam in August. If she fails an exam, then she
is not allowed to take any others. The probability that she passes the first exam is .9. If she passes
the first exam, then the conditional probability that she passes the second one is .8, and if she
passes both the first and the second exams, then the conditional probability
that she passes the third exam is .7.

(a)
What is the probability that she passes all three exams?\\

\comment{
(Solution)\\

Let $E_i$ denote the event where she passes the $i$-th exam. We have
$$
P(\textup{passes all exams}) = P(E_3E_2E_1) = P(E_3|E_2E_1)P(E_2|E_1)P(E_1) =
.7\times.8\times.9 = .504 $$
by the multiplication rule.\\
}

(b)
Given that she did not pass all three exams, what is the conditional probability that
she failed the second exam?\\

\comment{
(Solution)\\

Note that the event that she failed the second exam is $E_1E_2^c$ and the event that
she did not pass all three exams is $(E_1E_2E_3)^c$.
Solution is shown in Figure \ref{sol_problem1b}\\
\begin{figure}[h!tb]
\centering
\includegraphics[width=150mm] {a_1b.jpg}
\caption{Solution of Problem \ref{problem1}.b}
\label{sol_problem1b}
\end{figure}
}

\section{Conditional probability Problem 2}
An urn initially contains 5 white and 7 black balls. Each time a ball is selected, its color
is noted and it is replaced in the urn along with 2 other balls of the same color. Compute
the probability that

(a) the first 2 balls selected are black and the next 2 are white.\\

\comment{
(Solution)\\

Let a string of k letters, B or W, denote the choice of the first k balls, black or
white respectively. Then

$$
P(BBWW) = P(BBWW|BBW)P(BBW|BB)P(BB|B)P(B).
$$

$P(B) = 7/12$. If the first ball selected is black, then there are 5 white and 9 black
balls, so $P(BB|B) = 9/14$. If the first two balls selected are black, then there are
5 white and 11 black balls, so $P(BBW|BB) = 5/16$. If the first three balls are
BBW, then there are 7 white and 11 black balls, so $P(BBWW|BBW) = 7/18$.
Hence

$$
P(BBWW) = 1/18\times 5/16 \times 9/14 \times 7/12 = 35/768.
$$
}

(b) of the first 4 balls selected, exactly 2 are black.\\

\comment{
(Solution)\\

Using the same process as in part (a), we get that\\
\begin{align}
&P(BBWW) + P(BWBW) + P(BWWB)\\ \nonumber
&+ P(WBWB) + P(WBBW) + P(WWBB)\\ \nonumber
= & 7/18 \times 5/16\times9/14\times  7/12 + 7/18\times 9/16\times5/14\times
7/12\\ \nonumber
& + 9/18\times 7/16\times 7/14\times 5/12 + 7/18\times 9/16\times 7/14
\times 5/12\\ \nonumber
&+ 9/18\times 7/16\times 7/14\times 5/12\\ \nonumber
= & 13230/48384\\ \nonumber
\approx & .2734
\end{align}
}

\section{Bayes}
Prove the following statements.\\

(1) Bayes' Theorem:

$$
P(B|A) = \frac{P(A|B) P(B)}{\sum_b P(A|B=b)P(B=b)}
$$

\comment{
(Solution)\\
\begin{align} \nonumber
P(A\cup B) &= P(A|B)P(B)\\ \nonumber
&=P(B|A)P(A) \nonumber
\end{align}
\begin{align} \nonumber
P(B|A) &= \frac{P(A\cup B)}{P(A)} \\ \nonumber
&=\frac{P(A|B)P(B)}{\sum_bP(A|B=b)P(B=b)} \nonumber
\end{align}

}


(2) If the events $A$ and $B$ are independent, then
$P(A|B) = P(A)$ and $P(B|A)=P(B)$.

\comment{
(Solution)\\
\begin{align}\nonumber
P(A\cup B) &= P(A)P(B) \\ \nonumber
P(A|B) &= \frac{P(A\cup B)}{P(B)} \\ \nonumber
&= \frac{P(A)P(B)}{P(B)} \\ \nonumber
&=P(A) 
\end{align}
\begin{align} \nonumber
P(B|A) &= \frac{P(B\cup A)}{P(A)} \\ \nonumber
&=\frac{P(B)P(A)}{P(A)} \\ \nonumber
&=P(B) 
\end{align}
}


\end{document}
