% \documentclass[serif]{beamer} % Serif for Computer Modern math font. \documentclass[serif, handout]{beamer} % Handout to ignore pause statements. \hypersetup{colorlinks,linkcolor=,urlcolor=red} \usefonttheme{serif} % Looks like Computer Modern for non-math text -- nice! \setbeamertemplate{navigation symbols}{} % Suppress navigation symbols % \usetheme{Berlin} % Displays sections on top \usetheme{Frankfurt} % Displays section titles on top: Fairly thin but still swallows some material at bottom of crowded slides %\usetheme{Berkeley} \usepackage[english]{babel} \usepackage{amsmath} % for binom \usepackage{amsfonts} % for \mathbb{R} The set of reals % \usepackage{graphicx} % To include pdf files! % \definecolor{links}{HTML}{2A1B81} % \definecolor{links}{red} \setbeamertemplate{footline}[frame number] \mode \title{Discrete Random Variables\footnote{ This slide show is an open-source document. See last slide for copyright information.} \\ (Sections 2.1-2.3 and parts of 2.5)} \subtitle{STA 256: Fall 2019} \date{} % To suppress date \begin{document} \begin{frame} \titlepage \end{frame} \begin{frame} \frametitle{Overview} \tableofcontents \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Random Variables} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Random Variable: The idea} %\framesubtitle{} The idea of a random variable is a \emph{measurement} conducted on the elements of the sample space. \pause \begin{itemize} \item $S$ could be the set of Canadian households, all equally likely to be sampled. \pause $X(s)$ is the number of people in household $s$. \pause \item Toss a coin with $P(\mbox{Head})=p$, three times. $S = \{HHH, HHT, HTH, HTT, THH, THT, TTH, TTT\}$. \pause $X(s)$ is the number of Heads for outcome $s$. \pause \item $X(s)$ could be one if $s$ is employed, and zero if $s$ is unemployed. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Formal Definition of a random variable} %\framesubtitle{} {\Large A random variable is a function from $S$ to the set of real numbers. \pause } % End size \vspace{5mm} \begin{itemize} \item This is consistent with the idea of measurement. \pause \item It takes an element $s$, and assigns a numerical value to it. \pause \item This is why we were writing $X(s)$. \pause \item Often, a random variable is denoted by $X$\pause, \item But it's really the function $X(s)$. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Probability statements about a random variable} \pause %\framesubtitle{} The probability that $X(s)$ will take on various numerical values is \emph{determined} by the probability measure on the subsets of $S$. \pause \vspace{4mm} {\LARGE \begin{displaymath} P(X=2) \pause = P\{ s \in S: X(s) = 2 \} \end{displaymath} \pause \begin{displaymath} P(X=x) = P\{ s \in S: X(s) = x \} \end{displaymath} } \pause There is a critical difference between capital $X$ and little $x$. \pause {\LARGE \begin{displaymath} P(X \in B) = P\{ s \in S: X(s) \in B \} \end{displaymath} } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Example} %\framesubtitle{} Toss a fair coin twice. \begin{itemize} \item $P\{HH\} = P\{HT\} = P\{TH\} = P\{TT\} = \frac{1}{4}$. \pause \item Let $X$ equal the number of heads. \pause \item $P(X=0) = P\{TT\} = \frac{1}{4}$. \item $P(X=1) = P\{HT, TH\} = \frac{1}{2}$. \item $P(X=2) = P\{HH\} = \frac{1}{4}$. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Distribution of a random variable} \framesubtitle{Leaves out some technicalities} {\large The \emph{distribution} of a random variable $X$ is the collection of probabilities $P(X \in B)$ for all $B \subseteq \mathbb{R}$. } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Discrete Random Variables} \pause %\framesubtitle{} The random variable $X$ is said to be \emph{discrete} if there exist distinct $x_1, x_2, \ldots$ (perhaps only finitely many) with \pause \begin{itemize} \item $P(X = x_j) > 0$ for all $j$, and \pause \item $\sum_{j = 0}^\infty P(X = x_j) = 1$. \end{itemize} \pause \vspace{5mm} A better definition (for some people): The random variable $X: S \rightarrow \mathbb{R}$ is said to be discrete if its range is countable. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Not all random variables are discrete} \pause %\framesubtitle{} The random variable $X$ is said to be \emph{discrete} if there exist distinct $x_1, x_2, \ldots$ (perhaps only finitely many) with \begin{itemize} \item $P(X = x_j) > 0$ for all $j$, and \item $\sum_{j = 0}^\infty P(X = x_j) = 1$. \end{itemize} \pause \vspace{5mm} Let the random variable $X$ take values in $(0,1)$, with $P(X \in B) = $ length of $B \cap (0,1)$. \pause Because $P(X=x)=0$ for all real $x$, the random variable $X$ is not discrete. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Probability Function of a discrete random variable} \framesubtitle{Also called the \textbf{probability mass function}} \pause Suppose the random variable $X$ takes on the values $x_1, \ldots, x_n$ or $x_1, x_2, \ldots$ with non-zero probability. The \emph{probability function} of $X$ is written \pause {\LARGE \begin{displaymath} p_{_X}(x) = P(X=x) \end{displaymath} } % End size for all real $x$. \pause \vspace{5mm} For the 2 fair coins example, $p_{_X}(0) = \frac{1}{4}$, $p_{_X}(1)=\frac{1}{2}$ and $p_{_X}(2)=\frac{1}{4}$.\pause \vspace{3mm} $p_{_X}(14)=0$. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Cumulative Distribution Function} \pause %\framesubtitle{} The \emph{cumulative distribution function} of a random variable $X$ is defined by \pause {\LARGE \begin{displaymath} F_{_X}(x) = P(X \leq x) \end{displaymath} \pause } % End size \begin{itemize} \item Note that $X$ is the random variable, and $x$ is a particular numerical value. \pause % \item You will frequently see things like $P(X=x)$. \pause There is a critical difference between capital $X$ and little $x$. \pause \item $F(x)$ is defined for all real $x$. \pause \item $F(x)$ is non-decreasing. \pause This is because \pause \item If $x_1 < x_2$, $\{s: X(s) \leq x_1 \} \subseteq \{s: X(s) \leq x_2 \}$. \pause \item $\lim_{x \rightarrow - \infty} F(x) = 0$ and $\lim_{x \rightarrow \infty} F(x) = 1$. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Cumulative distribution function for the coin toss example} \framesubtitle{Fig. 2.5.1 on page 65 gets only part marks. CDFs are right continuous.} \begin{center} \includegraphics[width=4in]{cdf} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Common Discrete Distributions} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Common Discrete Distributions} %\framesubtitle{} \begin{itemize} \item The Degenerate distribution \item The Bernoulli distribution \item The Binomial distribution \item The Geometric distribution \item The Negative Binomial distribution \item The Poisson distribution \item The Hypergeometric distribution \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Degenerate distribution} \framesubtitle{Example 2.3.1} {\LARGE \begin{displaymath} p_{_X}(x) = \left\{ \begin{array}{ll} % ll means left left 1 & \mbox{for } x=c \\ 0 & \mbox{for } x \neq c \end{array} \right. % Need that crazy invisible right period! \end{displaymath} } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The Bernoulli Distribution} \framesubtitle{Example 2.3.2} \begin{itemize} \item Simple probability model: Toss a coin with $P(\mbox{Head})=\theta$, one time. Let $X$ equal the number of heads. \pause \item Probability (mass) function of $X$: \pause \begin{displaymath} p_{_X}(x) = \left\{ \begin{array}{ll} % ll means left left \theta^x(1-\theta)^{1-x} & \mbox{for $x = 0$ or 1} \\ 0 & \mbox{Otherwise} \end{array} \right. % Need that crazy invisible right period! \end{displaymath} \pause \item An \emph{indicator random variable} equals one if some event happens, and zero if it does not happen. \pause \begin{itemize} \item 1=Female, 0=Male \pause \item 1=Lived, 0=Died \pause \item 1=Passed, 0=Failed \pause \end{itemize} \item Indicators are usually assumed to have a Bernoulli distribution. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The Binomial Distribution} \framesubtitle{Example 2.3.3} \pause \begin{itemize} \item Simple probability model: Toss a coin with $P(\mbox{Head})=\theta$. \pause Toss it $n$ times. Let $X$ equal the number of heads. \pause \item Probability (mass) function of $X$: \pause \begin{displaymath} p_{_X}(x) = \left\{ \begin{array}{ll} % ll means left left \binom{n}{x}\theta^x(1-\theta)^{n-x} & \mbox{for $x = 0, 1, \ldots, n$} \\ ~0 & \mbox{Otherwise} \end{array} \right. % Need that crazy invisible right period! \end{displaymath} \pause \item The Bernoulli is a special case of the Binomial, with $n=1$. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} % Maybe omit or by-pass \frametitle{Why does $p_{_X}(x) = \binom{n}{x}\theta^x(1-\theta)^{n-x}$} \framesubtitle{For the Binomial Distribution?} \pause Toss a coin $n$ times with $P(\mbox{Head})=\theta$, and let $X$ equal the number of heads. Why does $P(X=x) = \binom{n}{x}\theta^x(1-\theta)^{n-x}$? \begin{itemize} \item The sample space is the set of all strings of $n$ letters composed of H and T. \item By the Multiplication Principle, there are $2^n$ elements. % Think of a tree. \item If two different strings have $x$ heads (and $n-x$ tails), they have the same probability. \item For example, $P\{HHTH\} = P\{THHH\} = \theta^3(1-\theta)$ by independence. \item Count the number of ways that $x$ positions out of $n$ can be chosen to have the symbol H. \item $n$ choose $x$ is $\binom{n}{x} = \frac{n!}{x!(n-x)!}$. \item So $P(X=x) = \binom{n}{x}\theta^x(1-\theta)^{n-x}$ ~ $\blacksquare$ \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Geometric Distribution} \framesubtitle{Example 2.3.4} \pause \begin{itemize} \item Simple probability model: Toss a coin with $P(\mbox{Head})=\theta$ until the first head appears, and then stop. Let $X$ equal the number of times the coin comes up tails, \emph{before} the head occurs. \pause \item Probability (mass) function of $X$: \pause \begin{displaymath} p_{_X}(x) = \left\{ \begin{array}{ll} % ll means left left (1-\theta)^x\,\theta & \mbox{for $x = 0, 1, \ldots $} \\ ~0 & \mbox{Otherwise} \end{array} \right. % Need that crazy invisible right period! \end{displaymath} \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Negative Binomial Distribution} \framesubtitle{Example 2.3.5} \pause % This formulation makes it hard to apply to simple problems. \begin{itemize} \item Simple probability model: Toss a coin with $P(\mbox{Head})=\theta$ until $r$ heads appear, and then stop. Let $X$ equal the number of tails before observing the $r$th head. \pause \item First we observe $r-1$ heads and $x$ tails, in no particular order. \pause \item Then we observe another head. \pause \item For $x = 0, 1, \ldots$, the probability (mass) function is \end{itemize} \begin{eqnarray*} p_{_X}(x) & = & \binom{x+r-1}{x} \theta^{r-1}(1-\theta)^x \pause \theta \\ \pause & = & \binom{x+r-1}{x} \theta^r (1-\theta)^x \end{eqnarray*} \pause The Geometric distribution is a special case of the negative binomial, with $r=1$. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Poisson distribution} \framesubtitle{Example 2.3.6} Useful for count data. For example, \pause \begin{itemize} \item Number of rasins in a loaf of rasin bread. \pause \item Number of alpha particles emitted from a radioactive substance in a given time interval. \pause \item Number of calls per minute coming in to a customer service line. \pause \item Bomb craters in London during WWII. \pause \item Number of rat hairs in a jar of peanut butter. \pause \item Number of deaths per year from horse kicks in the Prussian army, 1878-1898. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Conditions for the Poisson distribution} \pause %\framesubtitle{} We are usually counting events that happen in an interval, or in a region of time or space (or both). \pause The following are rough translations for the technical conditions for the number of events to have a Poisson distribution. \pause \begin{itemize} \item Independent increments: \pause The occurrence of events in separate intervals (regions) are independent. \pause \item The probability of observing at least one event in an interval or region is roughly proportional to the size of the interval or region. \pause \item As the size of the region or interval approaches zero, the probability of more than one event in the region or interval goes to zero. \pause \end{itemize} If these conditions are approximately satisfied, the probability distribution of the number of events will be approximately Poisson. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Poisson Probability Function, with parameter $\lambda>0$} {\LARGE \begin{displaymath} p_{_X}(x) = \left\{ \begin{array}{ll} % ll means left left \frac{e^{-\lambda}\, \lambda^x}{x!} & \mbox{for $x = 0, 1, \ldots $} \\ ~~~0 & \mbox{Otherwise} \end{array} \right. % Need that crazy invisible right period! \end{displaymath} \pause } % End size \vspace{5mm} Where the parameter $\lambda>0$. \pause \vspace{5mm} Note $ \displaystyle\sum_{x=0}^\infty p_{_X}(x) \pause = \sum_{x=0}^\infty \frac{e^{-\lambda}\, \lambda^x}{x!} \pause = e^{-\lambda}\,\sum_{x=0}^\infty \frac{ \lambda^x}{x!} \pause = e^{-\lambda} e^{\lambda} \pause = 1$. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Hypergeometric Distribution} \framesubtitle{Example 2.3.7} \pause \begin{itemize} \item Simple probability model: Jar with $N$ balls, of which $M$ are white and $N-M$ are black. Randomly sample $n \leq N$ balls without replacement. Let $X$ denote the number of white balls in the sample. \pause \item Probability function of $X$: \pause \begin{displaymath} p_{_X}(x) = \frac{ \binom{M}{x}\binom{N-M}{n-x} }{\binom{N}{n}} \end{displaymath} \pause \item But for what values of $x$ is this correct? \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{$p_{_X}(x) = \frac{ \binom{M}{x}\binom{N-M}{n-x} }{\binom{N}{n}} $} \framesubtitle{For some values of $x$. For all other values, $p_{_X}(x) = 0$} \pause {\small Jar with $N$ balls, $M$ white and $N-M$ black. Sample $n \leq N$ balls. $X =$ number of white balls selected. \pause \begin{itemize} \item Definitely $0 \leq x \leq n$. \pause \item Look at the binomial coefficients. You cannot sample more objects than you have. \pause \item So $x \leq M$. \pause And we have $x \leq \min(n,M)$. \pause \item Also $n-x \leq N-M \pause \Leftrightarrow x \geq n-(N-M)$ \pause \item This last restriction makes sense. Suppose the size of the sample is greater than the number of black balls (possible). \pause Like there are 7 white and 3 black, and you choose 5 balls. \pause You will get at least 2 white balls. \pause $x \geq n - (N-M)$ \pause \item $x \geq 0$ and $x \geq n - (N-M)$\pause, so $x \geq \max[n - (N-M),0]$. \end{itemize} } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Putting it all together} \framesubtitle{The Hypergeometric Distribution} Jar with $N$ balls, $M$ white and $N-M$ black. Sample $n \leq N$ balls. $X =$ number of white balls selected. %{\LARGE \begin{displaymath} p_{_X}(x) = \left\{ \begin{array}{cl} % cl means centr left \frac{ \binom{M}{x}\binom{N-M}{n-x} }{\binom{N}{n}} & \mbox{for $x = \max[n - (N-M),0], \ldots, \min[n,M]$} \\ &\\ 0 & \mbox{Otherwise} \end{array} \right. % Need that crazy invisible right period! \end{displaymath} \pause %} % End size \vspace{5mm} The set of values where a random variable has positive probability is called its \emph{support}. \end{frame} % \item \pause %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The big Three} %\framesubtitle{} The most useful discrete distributions in applications are \begin{itemize} \item Bernoulli \item Binomial \item Poisson \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Copyright Information} This slide show was prepared by \href{http://www.utstat.toronto.edu/~brunner}{Jerry Brunner}, Department of Statistical Sciences, University of Toronto. It is licensed under a \href{http://creativecommons.org/licenses/by-sa/3.0/deed.en_US} {Creative Commons Attribution - ShareAlike 3.0 Unported License}. Use any part of it as you like and share the result freely. The \LaTeX~source code is available from the course website: \vspace{5mm} \href{http://www.utstat.toronto.edu/~brunner/oldclass/256f19} {\small\texttt{http://www.utstat.toronto.edu/$^\sim$brunner/oldclass/256f19}} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $ = \{s \in S: \}$ \begin{frame} \frametitle{} \pause %\framesubtitle{} \begin{itemize} \item \pause \item \pause \item \end{itemize} \end{frame}