% \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{Continuous Random Variables\footnote{ This slide show is an open-source document. See last slide for copyright information.}} \subtitle{STA 256: Fall 2018} \date{} % To suppress date \begin{document} \begin{frame} \titlepage \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Continuous Random Variables} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Continuous Random Variables: The idea} \framesubtitle{Probability is area under a curve} \pause %{\small \begin{itemize} \item Discrete random variables take on a finite or countably infinite number of values. \pause \item Continuous random variables take on an \emph{uncountably infinite} number of values. \pause \item This implies that $\Omega$ is uncountable too, but we seldom talk about it. \pause \item Probability is area under a curve \pause --- that is, area between a curve and the $x$ axis. \pause \begin{center} \includegraphics[width=3in]{area} \end{center} % \pause % Maybe end with this. % \item Nature may be fundamentally discrete. \pause % \item If so, continuous probability is a convenient approximation. \end{itemize} %} % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The Probability Density Function} \pause %\framesubtitle{} \begin{center} \includegraphics[width=3in]{area} \end{center} \pause \begin{displaymath} P(a 1$, \pause \begin{eqnarray*} F(x) &=& \int_{-\infty}^0 0 \, dt + \int_0^1 2t \, dt +\int_1^x 0 \, dt \\ \pause &=& 0 + 1 + 0 \\ \pause &=& 1 \end{eqnarray*} \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Putting the pieces together} \pause %\framesubtitle{} {\LARGE \begin{displaymath} F(x) = \left\{ \begin{array}{ll} % ll means left left 0 & \mbox{for $x < 0$} \\ x^2 & \mbox{for } 0 \leq x \leq 1 \\ 1 & \mbox{for } x > 1 \end{array} \right. % Need that crazy invisible right period! \end{displaymath} \pause } % End size \vspace{10mm} The derivation does not need to be this detailed, but the final result has to be complete. More examples will be given. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Common Continuous Distributions} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Common Continuous Distributions} %\framesubtitle{} \begin{itemize} \item Uniform \item Exponential \item Gamma \item Normal \item Beta \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The Uniform Distribution: $X\sim$ Uniform$(a,b)$} \framesubtitle{Parameters $a 0$} \begin{columns} \column{0.5\textwidth} {\large \begin{displaymath} f(x) = \left\{ \begin{array}{ll} % ll means left left \lambda e^{-\lambda x} & \mbox{for $x \geq 0$} \\ 0 & \mbox{for } x < 0 \end{array} \right. % Need that crazy invisible right period! \end{displaymath} \pause } % End size \column{0.5\textwidth} \begin{center} \includegraphics[width=2.4in]{Exponential} \end{center} \end{columns} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The Gamma Distribution: $X\sim$ Gamma($\alpha,\lambda$)} \framesubtitle{Parameters $\alpha>0$ and $\lambda > 0$} \begin{columns} \column{0.5\textwidth} {\small \begin{displaymath} f(x) = \left\{ \begin{array}{ll} % ll means left left \frac{\lambda^\alpha}{\Gamma(\alpha)} e^{-\lambda x} \, x^{\alpha-1} & \mbox{for $x \geq 0$} \\ 0 & \mbox{for } x < 0 \end{array} \right. % Need that crazy invisible right period! \end{displaymath} \pause } % End size \column{0.5\textwidth} \begin{center} \includegraphics[width=2.2in]{Gamma} \end{center} \pause \end{columns} \vspace{1mm} {\small The gamma function is defined by $\Gamma(\alpha) = \int_0^\infty e^{-t} \, t^{\alpha-1} \, dt$ \pause \vspace{2mm} Integration by parts shows $\Gamma(\alpha+1) = \alpha \, \Gamma(\alpha)$. } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The Normal Distribution: $X\sim$ N($\mu,\sigma$)} \framesubtitle{Parameters $\mu \in \mathbb{R}$ and $\sigma > 0$} \begin{columns} \column{0.5\textwidth} %{\large \begin{eqnarray*} f(x) & = & \frac{1}{\sigma \sqrt{2\pi}}e^{-\frac{(x-\mu)^2}{2\sigma^2}} \\ \pause & = & \frac{1}{\sigma \sqrt{2\pi}}\exp - \left\{{\frac{(x-\mu)^2}{2\sigma^2}}\right\} \end{eqnarray*} \pause %} % End size \column{0.5\textwidth} \begin{center} \includegraphics[width=2.1in]{Normal} \end{center} \pause \end{columns} \vspace{1mm} The normal distribution is also called the Gaussian, or the ``bell curve." if $\mu=0$ and $\sigma=1$, we write $X\sim$ N(0,1) and call it the \emph{standard normal}. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The Beta Distribution: $X\sim$ Beta($\alpha,\beta$)} \framesubtitle{Parameters $\alpha>0$ and $\beta > 0$} {\Large \begin{displaymath} f(x) = \left\{ \begin{array}{ll} % ll means left left \frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)} \, x^{\alpha-1} (1-x)^{\beta-1} & \mbox{for $0 \leq x \leq 1$} \\ 0 & \mbox{Otherwise} \end{array} \right. % Need that crazy invisible right period! \end{displaymath} \pause \vspace{3mm} } % End size \vspace{3mm} Using $\Gamma(n+1) = n \, \Gamma(n)$ and $\Gamma(\beta) = \int_0^\infty e^{-t} \, t^{\beta-1} \, dt$, note that a beta distribution with $\alpha=\beta=1$ is Uniform(0,1). \pause \vspace{2mm} The beta density can assume a variety of shapes, depending on the parameters $\alpha$ and $\beta$. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Beta density with $\alpha=5$ and $\beta=5$} %\framesubtitle{} \begin{center} \includegraphics[width=3.1in]{Beta55} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Beta density with $\alpha=8$ and $\beta=2$} %\framesubtitle{} \begin{center} \includegraphics[width=3.1in]{Beta82} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Beta density with $\alpha=2$ and $\beta=8$} %\framesubtitle{} \begin{center} \includegraphics[width=3.1in]{Beta28} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Beta density with $\alpha=\frac{1}{2}$ and $\beta=\frac{1}{2}$} %\framesubtitle{} \begin{center} \includegraphics[width=3.1in]{BetaHalfHalf} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Functions of a Random Variable} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Functions of a Random Variable} \pause %\framesubtitle{} \begin{itemize} \item Suppose you know the probability distribution of $X$. \pause \item $Y=g(X)$. \pause \item What is the probability distribution of $Y$? \pause \item For example, $X$ is miles per gallon. \pause \item $Y$ is litres per 100 kilometers for the same population of cars. \pause \item You can make probability statements about $X$, but you need to make probability statements about $Y$ \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{General approach to finding the density of $Y=g(X)$} \pause %\framesubtitle{} First, find the set of $y$ values where $f_y(y)>0$. \pause %\vspace{3mm} \begin{itemize} \item There are infinitely many right answers, differing only on a set of probability zero. \pause \item If $f_x(x)>0$, let $f_y(y)>0$ for $y=g(x)$. \pause This works. \pause % Expected value of indicator, change of variables theorem. \item Then, for \emph{one of those $y$ values} (assuming $f_y(y)$ continuous there), \pause \begin{displaymath} f_y(y) = \frac{d}{dy} \, F_y(y) \pause = \frac{d}{dy} \, P(Y \leq y) \end{displaymath} \pause \item Substitute for $Y$ in terms of $X$. \pause \item Try to solve for $X$. \pause \item Express in terms of the cdf $F_x(x)$. \pause \item Differentiate with respect to $y$. \pause \item Usually use the chain rule. \pause \item We need an example. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Example} %\framesubtitle{} Let $X\sim$ Gamma($\alpha,\lambda$) \pause and $Y = 2X$. \pause Find the density of $Y$. \pause \begin{displaymath} f_x(x) = \left\{ \begin{array}{ll} % ll means left left \frac{\lambda^\alpha}{\Gamma(\alpha)}e^{-\lambda x} \, x^{\alpha-1} & \mbox{for $x \geq 0$} \\ 0 & \mbox{for } x < 0 \end{array} \right. % Need that crazy invisible right period! \end{displaymath} \pause First, where will $f_y(y)$ be non-zero? \pause \begin{itemize} \item $f_x(x)>0$ for $x \geq 0$. \pause \item $x \geq 0 \pause \Leftrightarrow y=2x \geq 0$. \pause \item So, for $y \geq 0$, \ldots \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Derive the functional part of $f_y(y)$} \framesubtitle{$X\sim$ Gamma($\alpha,\lambda$) and $Y = 2X$} \pause \begin{columns} \column{0.4\textwidth} \begin{eqnarray*} f_y(y) & = & \frac{d}{dy} \, F_y(y) \\ \pause & = & \frac{d}{dy} \, P(Y \leq y) \\ \pause & = & \frac{d}{dy} \, P(2X \leq y) \\ \pause & = & \frac{d}{dy} \, P\left(X \leq \frac{1}{2}y\right) \\ \pause & = & \frac{d}{dy} \, F_x\left(\frac{1}{2}y\right) \\ \pause \end{eqnarray*} \column{0.6\textwidth} \begin{eqnarray*} & = & f_x\left(\frac{1}{2}y\right) \pause \cdot \pause \frac{d}{dy} \frac{1}{2}y\\ \pause & = & \frac{1}{2} \cdot \pause \frac{\lambda^\alpha}{\Gamma(\alpha)} \exp\left\{-\lambda \frac{1}{2}y\right\} \, \left(\frac{1}{2}y\right)^{\alpha-1} \\ \pause & = & \frac{(\lambda/2)^\alpha}{\Gamma(\alpha)} \exp\left\{- \frac{\lambda}{2}y\right\} \, y^{\alpha-1} \\ \pause && \\ % Put blank lines lines to align columns. && \\ && \\ && \\ \end{eqnarray*} \end{columns} Compare gamma density: $f_x(x) = \frac{\lambda^\alpha}{\Gamma(\alpha)}e^{-\lambda x} \, x^{\alpha-1}$ for $x \geq 0$. \pause Conclude $Y\sim$ Gamma($\alpha,\lambda/2$). \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Give the density of $Y$} \framesubtitle{Don't forget to specify where $f_y(y)>0$} \pause {\LARGE \begin{displaymath} f_y(y) = \left\{ \begin{array}{ll} % ll means left left \frac{(\lambda/2)^\alpha}{\Gamma(\alpha)} \exp\left\{- \frac{\lambda}{2}y\right\} \, y^{\alpha-1}, & \mbox{for $y \geq 0$} \\ 0 & \mbox{for } y < 0 \end{array} \right. % Need that crazy invisible right period! \end{displaymath} } % End size \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/256f18} {\small\texttt{http://www.utstat.toronto.edu/$^\sim$brunner/oldclass/256f18}} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $ = \{\omega \in \Omega: \}$ \begin{frame} \frametitle{} \pause %\framesubtitle{} \begin{itemize} \item \pause \item \pause \item \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% R work for density plots rm(list=ls()) # Uniform tstring = 'Uniform(a,b) density with a=0 and b=1' x = seq(from=0,to=1,by=0.01); Density = x-x + 1 plot(x,Density,type = 'l',main=tstring) # Exponential tstring = expression(paste('Exponential(',lambda,') density with ',lambda,'= 1')) x = seq(from=0,to=4,by=0.05); Density = exp(-x) plot(x,Density,type = 'l',main=tstring) # Gamma tstring = expression(paste('Gamma(',alpha,',',lambda,') density with ', alpha,' = 3 and ',lambda,'= 1')) x = seq(from=0,to=10,by=0.05); Density = dgamma(x,shape=3,rate=1) plot(x,Density,type = 'l',main=tstring) # Normal tstring = expression(paste('Normal(',mu,',',sigma,') density with ', mu,' = 0 and ',sigma,'= 1')) x = seq(from=-4,to=4,by=0.05); Density = dnorm(x) plot(x,Density,type = 'l',main=tstring) # Beta tstring = expression(paste('Beta(',alpha,',',beta,') density with ', alpha,' = 5 and ',beta,'= 5')) x = seq(from=0,to=1,by=0.01); Density = dbeta(x,5,5) plot(x,Density,type = 'l',main=tstring)