\begin{frame}
  \myheading{Module 17.0: Recap of Probability Theory}
\end{frame}

\begin{frame}
We will start with a quick recap of some basic concepts from probability
\end{frame}

\begin{frame}
  \begin{columns}
    \column{0.5\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
    \centering
    \vspace{1.5cm}
    \onslide<3->{
     \input{modules/ModuleRecapPrimer/tikz_images/disjoint.tex}
     }
     \end{overlayarea}

    \column{0.5\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
          \vspace{0.5cm}
     \textbf{Axioms of Probability}
     \begin{itemize}\justifying
     \item<2-> For any event $A$,
     \begin{align*}
     P(A) \geq 0
     \end{align*}
     \item<3-> If $A_1, A_2, A_3, ...., A_n$ are disjoint events (i.e., $A_i \cap A_j = \phi \quad \forall i \ne j$) then 
     \begin{align*}
     P(\cup A_i) = \sum_{i} P(A_i)
     \end{align*}
     \item<4-> If $\Omega$ is the universal set containing all events then
     \begin{align*}
     P(\Omega) = 1
     \end{align*}

	\end{itemize}     

      \end{overlayarea} 
  \end{columns}
\end{frame}


\begin{frame}
  \begin{columns}
    \column{0.5\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
\centering
\vspace{1.5cm}
\only<1-2>{
     \input{modules/ModuleRecapPrimer/tikz_images/three.tex}
}
\onslide<3->
{
     \input{modules/ModuleRecapPrimer/tikz_images/grades.tex}

}

     \end{overlayarea}

    \column{0.5\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
\vspace{0.5cm}
     \textbf{Random Variable (intuition)}
	\begin{itemize}\justifying
     \item<1-> Suppose a student can get one of 3 possible grades in a course: $A, B, C$
     \item<2-> One way of interpreting this is that there are 3 possible events here 
     \item<3-> Another way of looking at this is there is a \textit{random variable} $G$ which each student to one of the 3 possible values
     \item<4-> And we are interested in $P(G = g)$ where $g \in \{A, B, C\}$
     \item<5-> Of course, both interpretations are conceptually equivalent
	\end{itemize}     
     


      \end{overlayarea} 
  \end{columns}
\end{frame}


\begin{frame}
  \begin{columns}
    \column{0.5\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
\centering
\vspace{1.5cm}
\only<1>
{
     \input{modules/ModuleRecapPrimer/tikz_images/grades.tex}

}
\onslide<2->{
     \input{modules/ModuleRecapPrimer/tikz_images/height_and_age.tex}
}
     \end{overlayarea}

    \column{0.5\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
\vspace{0.5cm}
     \textbf{Random Variable (intuition)}
     \begin{itemize}\justifying
     \item<1-> But the second one (using random variables) is more compact
     \item<2-> Specially, when there are multiple attributes associated with a student (outcome) - \textit{grade, height, age,} \textit{etc.}
     \item<3-> We could have one random variable corresponding to each attribute
     \item<4-> And then ask for outcomes (or students) where $Grade=g$, $Height=h$, $Age=a$ and so on
	 \end{itemize}     
    


      \end{overlayarea} 
  \end{columns}
\end{frame}

\begin{frame}
  \begin{columns}
    \column{0.5\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
\centering
\vspace{1.5cm}
\onslide<1->{
     \input{modules/ModuleRecapPrimer/tikz_images/height_and_age.tex}
}
     \end{overlayarea}

    \column{0.5\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
\vspace{0.5cm}

     \textbf{Random Variable (formal)}
     \begin{itemize}\justifying
     \item<2-> A random variable is a \textbf{\textit{function}} which maps each outcome in $\Omega$ to a value
     \item<3-> In the previous example, $G$ (or $f_{grade}$) maps each student in $\Omega$ to a value: $A$, $B$ or $C$
     \item<4-> The event $Grade = A$ is a shorthand for the event $\{ \omega \in \Omega : f_{Grade} = A\}$ 
	 \end{itemize}     
    


      \end{overlayarea} 
  \end{columns}
\end{frame}

\begin{frame}
  \begin{columns}
    \column{0.5\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
\centering
\vspace{1.5cm}
\onslide<1->{
     \input{modules/ModuleRecapPrimer/tikz_images/height_and_weight.tex}
}

     \end{overlayarea}

    \column{0.5\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
\vspace{0.5cm}
     \textbf{Random Variable (continuous v/s discrete)}
     \begin{itemize}\justifying
     \item<1-> A random variable can either take continuous values (for example, $weight, height$)
     \item<2-> Or discrete values (for example, $grade, nationality$)
     \item<3-> For this discussion we will mainly focus on discrete random variables
	 \end{itemize}     
     

      \end{overlayarea} 
  \end{columns}
\end{frame}



\begin{frame}
  \begin{columns}
    \column{0.5\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
    	\vspace{2cm}
    	\begin{center}
    		\onslide<3->{\begin{tabular}{ |p{1cm}|p{1.2cm}| }
    						\hline
    					    $G$ & $P(G=g)$\\
    						\hline
    						A & 0.1 \\
    						B & 0.2 \\
    					    C & 0.7 \\
    						\hline
    					\end{tabular}}
    	\end{center}
     \end{overlayarea}

    \column{0.5\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
      \vspace{0.5cm}
     \textbf{Marginal Distribution}
     \begin{itemize}\justifying
	     \item<1-> What do we mean by \textit{\textbf{marginal distribution}} over a random variable ? 
	     \item<2-> Consider our random variable $G$ for grades 
	     \item<3-> Specifying the marginal distribution over $G$ means specifying
	     \begin{align*}			
	     	P (G = g) \quad \forall g \in {A, B, C}
		 \end{align*}
		 \item<4-> We denote this marginal distribution compactly by $P(G)$
	 \end{itemize}     

      \end{overlayarea} 
  \end{columns}
\end{frame}

\begin{frame}
  \begin{columns}
    \column{0.4\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
    	\vspace{2cm}
    	\begin{center}
    		\onslide<3->{\begin{tabular}{ |p{1cm}|p{1cm}|p{2.8cm}| }
    						\hline
    					    $G$ & $I$ & $P(G=g,I=i)$\\
    						\hline
    						A & High & $0.3$\\
    						A & Low & $0.1$\\
    					    B & High & $0.15$\\
    					    B & Low & $0.15$\\
    					    C & High & $0.1$\\
    					    C & Low & $0.2$\\
    						\hline
    					\end{tabular}}
    	\end{center}
     \end{overlayarea}

    \column{0.6\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
      \vspace{0.5cm}
     \textbf{Joint Distribution}
     \begin{itemize}\justifying
	     \item<1-> Consider two random variable $G$ (grade) and $I$ (intellegence $\in$ \{\textbf{H}igh, \textbf{L}ow\}) 
	     \item<2-> The joint distribution over these two random variables assigns probabilities to all events involving these two random variables
	     \begin{align*}			
	     	P (G = g, I = i) \quad &\forall (g,i) \in \{A, B, C\} \times \{H, L\}
		 \end{align*}
		 \item<4-> We denote this joint distribution compactly by $P(G, I)$
	 \end{itemize}     

      \end{overlayarea} 
  \end{columns}
\end{frame}

\begin{frame}
  \begin{columns}
    \column{0.3\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
    	\vspace{1cm}
    	% \begin{center}
    		\begin{tabular}{ |p{1cm}|p{2.2cm}| }
				\hline
			    $G$ & $P(G|I=H)$\\
				\hline
				A & 0.6 \\
				B & 0.3 \\
			    C & 0.1 \\
				\hline
			\end{tabular}
			\newline
			\newline
			\begin{tabular}{ |p{1cm}|p{2.2cm}| }
				\hline
			    $G$ & $P(G|I=L)$\\
				\hline
				A & 0.3 \\
				B & 0.4 \\
			    C & 0.3 \\
				\hline
			\end{tabular}
    	% \end{center}
     \end{overlayarea}

    \column{0.7\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
      \vspace{0.5cm}
     \textbf{Conditional Distribution}
     \begin{itemize}\justifying
	     \item<1-> Consider two random variable $G$ (grade) and $I$ (intellegence) 
	     \item<2-> Suppose we are given the value of $I$ (say, $I=H$) then the conditional distribution  $P(G|I)$ is defined as
	     \begin{align*}			
	     	P(G=g|I=H) = \frac{P(G=g, I=H)}{P(I=H)} \forall g \in \{A, B, C\}
		 \end{align*}
		 \item<3-> More compactly defined as 
	     \begin{align*}			
	     	P(G|I) &= \frac{P(G, I)}{P(I)} \\
	     	or \quad \underbrace{P(G, I)}_{joint} &= \underbrace{P(G|I)}_{conditional} * \underbrace{P(I)}_{marginal}
		 \end{align*}
	 \end{itemize}     

      \end{overlayarea} 
  \end{columns}
\end{frame}


\begin{frame}
  \begin{columns}
    \column{0.4\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
    	\vspace{2cm}
    	\begin{center}
    		\begin{tabular}{ |p{0.5cm}|p{0.5cm}|p{0.5cm}|p{2.9cm}| }
				\hline
			    $X_1$ & $\dots$ & $X_{n}$ & $P(X_1,X_2,\dots,X_n)$\\
				\hline
				$\dots$ & $\dots$ & $\dots$ & $\dots$\\
				$\dots$ & $\dots$ & $\dots$ & $\dots$\\
				$\dots$ & $\dots$ & $\dots$ & $\dots$\\
				\hline
			\end{tabular}
    	\end{center}
    	\begin{flushright}
    		$\sum = 1$
    	\end{flushright}
     \end{overlayarea}

    \column{0.6\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
      \vspace{0.5cm}
     \textbf{Joint Distribution ($n$ random variables)}
     \begin{itemize}\justifying
	     \item<1-> The joint distribution of $n$ random variables assigns probabilities to all events involving the $n$ random variables,
	     \item<2-> In other words it assigns
	     \begin{align*}			
	     	P(X_1 = x_1, X_2 = x_2, ..., X_n = x_n) \\
	     	\textit{for all possible values that variable $X_i$ can take}
		 \end{align*}
	     \item<3-> If each random variable $X_i$ can take two values then the joint distribution will assign probabilities to the $2^n$ possible events

	 \end{itemize}     

      \end{overlayarea} 
  \end{columns}
\end{frame}


\begin{frame}
  \begin{columns}
    \column{0.4\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
    	\vspace{2cm}
    	\begin{center}
    		\begin{tabular}{ |p{0.5cm}|p{0.5cm}|p{0.5cm}|p{2.9cm}| }
				\hline
			    $X_1$ & $\dots$ & $X_{n}$ & $P(X_1,X_2,\dots,X_n)$\\
				\hline
				$\dots$ & $\dots$ & $\dots$ & $\dots$\\
				$\dots$ & $\dots$ & $\dots$ & $\dots$\\
				$\dots$ & $\dots$ & $\dots$ & $\dots$\\
				\hline
			\end{tabular}
    	\end{center}
     \end{overlayarea}

    \column{0.6\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
      \vspace{0.5cm}
     \textbf{Joint Distribution ($n$ random variables)}
     \begin{itemize}\justifying
	     \item<1-> The joint distribution over two random variables $X_1$ and $X_2$ can be written as,
	     \vspace{-0.1in}
	     \begin{align*}			
	     	P(X_1, X_2) &= P(X_2|X_1)P(X_1) 
						= P(X_1|X_2)P(X_2)
		 \end{align*}
	     \item<2-> Similarly for $n$ random variables 
	     \vspace{-0.1in}
	      \begin{align*}			
	     	& P(X_1, X_2, ..., X_n) \\ \onslide<3->{&= P(X_2, ..., X_n|X_1)P(X_1)} \\
	     						  \onslide<4->{&= P(X_3, ..., X_n|X_1, X_2)P(X_2|X_1)P(X_1)} \\
	     						  \onslide<5->{&= P(X_4, ..., X_n|X_1, X_2, X_3)P(X_3|X_2, X_1) \\
	     						   	     						  &\quad P(X_2|X_1)P(X_1)} \\
	     						  \onslide<6->{&= P(X_1)\prod_{i=2}^{n} P(X_i| X_{1}^{i-1})	\quad \textit{\textbf{(chain rule)}}}
		 \end{align*}

	 \end{itemize}     

      \end{overlayarea} 
  \end{columns}
\end{frame}

\begin{frame}
  \begin{columns}
    \column{0.4\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
    	\vspace{1cm}
    	% \begin{center}
    		\begin{tabular}{ |p{1cm}|p{1cm}|p{2.8cm}| }
				\hline
			    $A$ & $B$ & $P(A=a,B=b)$\\
				\hline
				High & High & 0.3\\
				High & Low & 0.25\\
			    Low & High & 0.35\\
			    Low & Low & 0.1\\
				\hline
			\end{tabular}
			\newline
			\newline
			\begin{tabular}{ |p{1cm}|p{2cm}|p{2.9cm}| }
				\hline
			    $A$ & $P(A=a)$\\
				\hline
				High & 0.55\\
				Low & 0.45\\
				\hline
			\end{tabular}
			\newline
			\newline
			\begin{tabular}{ |p{1cm}|p{2cm}|p{3cm}| }
				\hline
			    $B$ & $P(B=a)$\\
				\hline
				High & 0.65\\
				Low & 0.35\\
				\hline
			\end{tabular}
    	% \end{center}
     \end{overlayarea}

    \column{0.6\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
      \vspace{0.5cm}
     \textbf{From Joint Distributions to Marginal Distributions}
     \begin{itemize}\justifying
	     \item<1-> Suppose we are given a joint distribtion over two random variables $A$, $B$ %(i.e., $P(A=a, B=b) \forall (a,b) $)
	     \item<2-> The marginal distributions of $A$ and $B$ can be computed as
	     \vspace{-0.1in}
	     \begin{align*}			
	     	P(A=a) &= \sum_{\forall b} P(A=a, B=b) \\
	     	P(B=b) &= \sum_{\forall a} P(A=a, B=b)
		 \end{align*}
	     \vspace{-0.2in}
		 \item<3-> More compactly written as
		 \vspace{-0.1in}
	     \begin{align*}			
	     	P(A) &= \sum_{B} P(A, B) \\
	     	P(B) &= \sum_{A} P(A, B)
		 \end{align*}
	 \end{itemize}     

      \end{overlayarea} 
  \end{columns}
\end{frame}

\begin{frame}
  \begin{columns}
    \column{0.4\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
    	\vspace{1cm}
    	% \begin{center}
    		\begin{tabular}{ |p{1cm}|p{1cm}|p{2.8cm}| }
				\hline
			    $A$ & $B$ & $P(A=a,B=b)$\\
				\hline
				High & High & 0.3\\
				High & Low & 0.25\\
			    Low & High & 0.35\\
			    Low & Low & 0.1\\
				\hline
			\end{tabular}
			\newline
			\newline
			\begin{tabular}{ |p{1cm}|p{1.8cm}|p{2cm}| }
				\hline
			    $A$ & $P(A=a)$\\
				\hline
				High & 0.55\\
				Low & 0.45\\
				\hline
			\end{tabular}
			\newline
			\newline
			\begin{tabular}{ |p{1cm}|p{1.8cm}|p{2cm}| }
				\hline
			    $B$ & $P(B=a)$\\
				\hline
				High & 0.65\\
				Low & 0.35\\
				\hline
			\end{tabular}
    	% \end{center}
     \end{overlayarea}

    \column{0.6\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
      \vspace{0.5cm}
     \textbf{What if there are $n$ random variables ?}
     \begin{itemize}\justifying
	     \item<1-> Suppose we are given a joint distribtion over $n$ random variables $X_1$, $X_2$, ..., $X_n$ %(i.e., $P(A=a, B=b) \forall (a,b) $)
	     \item<2-> The marginal distributions over $X_1$ can be computed as
	     \vspace{-0.1in}
	     \begin{align*}			
	     	&P(X_1=x_1) \\&= \sum_{\forall x_2, x_3, ..., x_n} P(X_1=x_1, X_2=x_2, ..., X_n = x_n)
		 \end{align*}
	     \vspace{-0.1in}
		 \item<3-> More compactly written as
		 \vspace{-0.1in}
	     \begin{align*}			
	     	P(X_1) &= \sum_{X_2, X_3, ..., X_n} P(X_1, X_2, ..., X_n)
		 \end{align*}
	 \end{itemize}     

      \end{overlayarea} 
  \end{columns}
\end{frame}

\begin{frame}
  \begin{columns}
    \column{0.4\textwidth}
    \begin{overlayarea}{\textwidth}{\textheight}
    	\vspace{1cm}
    	\begin{itemize}\justifying
	     	\item<5->Recall that by Chain Rule of Probability
	     		\begin{align*}
	     			P(X,Y) = P(X)P(Y|X)
	     		\end{align*}
	     	\item<6->However, if $X$ and $Y$ are independent, then
	     		\begin{align*}
	     			P(X,Y) = P(X)P(Y)
	     		\end{align*}
	 \end{itemize} 
     \end{overlayarea}

    \column{0.6\textwidth}
      \begin{overlayarea}{\textwidth}{\textheight}
      \vspace{0.5cm}
     \textbf{Conditional Independence}
     \begin{itemize}\justifying
	     \item<1-> Two random variables $X$ and $Y$ are said to be independent if 
	     \begin{align*}			
	     	P(X|Y) &= P(X)
		 \end{align*}
		 \item<2-> We denote this as $X \perp\!\!\!\perp Y$
	     \item<3-> In other words, knowing the value of $Y$ does not change our belief about $X$
		 \item<4-> We would expect \textit{\textbf{G}rade} to be dependent on \textit{\textbf{I}ntelligence} but independent of \textit{\textbf{W}eight}
	 \end{itemize}     

      \end{overlayarea} 
  \end{columns}
\end{frame}



\begin{frame}
Okay, we are now ready to move on to Bayesian Networks or Directed Graphical Models
\end{frame}
