STA237: Probability, Statistics, and Data Analysis I
PhD Student, DoSS, University of Toronto
Monday, May 29, 2023
Also called the expected value or mean.
The expectation of a discrete random variable \(X\) taking values \(x_1, x_2, \ldots\) and with probability mass function \(p\) is the number given by
\[E\left[X\right]=\sum_{i\in\{1,2,\ldots\}}x_i p\left(x_i\right).\]
Suppose Michael drinks \(Y\) cups of coffee
per day where \(Y\) is a random variable
that is defined by the probability mass function shown below.
What is the expected number of cups Michael drinks on any particular day?
\(p(8)=1-\frac{1}{6}-\frac{1}{6}-\frac{1}{3}-\frac{1}{6}=\frac{1}{6}\)
\(E[Y]=\sum_{y\in\{0,1,2,3,8\}}y p(y)\)
\(\phantom{E[Y]}=0\cdot\frac{1}{6} + 1 \cdot \frac{1}{6} + 2\cdot\frac{1}{3}\) \(\phantom{E[Y]=}+ 3\cdot\frac{1}{6} + 8\cdot\frac{1}{6}\)
\(\phantom{E[Y]}=\frac{8}{3}\approx 2.667\)
Suppose \(B\sim\text{Ber}(0.7)\).
What is \(E[B]\)?
In general,
\[E[B]=\theta\]
when \(B\sim\text{Ber}(\theta)\).
Suppose the probability that any person passing by Michael’s coffee shop buys a coffee from the shop is (0.05). How many non-customers do you expect to pass by before a customer comes in to the shop?
For simplicity, assume independent and identically distributed events for each person passing by the shop.
Recall a geometric series \(\sum_{k=0}^\infty ar^k=\frac{a}{1-r}\) when \(\lvert r\rvert<1\).
Recall \(N\sim\text{Geo}(0.05)\) is the number of people passing by until the first customer including the customer.
In general,
\[E[N]=\frac{1}{\theta}\]
when \(N\sim\text{Geo}(\theta)\).
The expectation of a continuous random variable \(X\) with probability density function \(f\) is the number given by
\[E\left[X\right]=\int_{-\infty}^\infty x f(x) dx.\]
Suppose \(X\) is a continuous random variable with pdf \(f\) defined by
\[f(x)=\begin{cases} 12\cdot x\cdot\left(1-x\right)^2 & x\in\left(0,1\right) \\ 0 & \text{otherwise.}\end{cases}\] Compute \(E[X]\).
Suppose Michael uses a coffee machine with time until failure of \(W\sim\text{Exp}(1/2)\) in months.
How long do you expect the machine to work without a failure?
\(E[W]=\int_{-\infty}^\infty w\cdot f(w) dw\)
\(\phantom{E[W]}=\int_{-\infty}^0 w\cdot 0 dw\) \(\phantom{E[W]=}+ \int_0^\infty w\cdot \frac{1}{2}e^{-w/2} dw\)
\(\phantom{E[W]}=\int_0^\infty w\cdot \frac{1}{2}e^{-w/2} dw\)
Apply integration by parts, \(\int_a^b u(x)v'(x)dx = \color{ForestGreen}{\left[u(x)v(x)\right]_a^b}-\color{DarkOrchid}{\int_a^b u'(x)v(x)dx}\).
Apply l’Hopital’s rule for \(\lim_{w\to\infty}w\left/e^{w/2}\right.\).
In general,
\[E[W]=\frac{1}{\lambda}\]
when \(W\sim\text{Exp}(\lambda)\).
To play the St. Petersburg game, you start by betting $2. At each round, you flip a fair coin. When it lands heads, your stake is doubled and you flip again. When it lands tails, the game ends and you take the money at stake.
What is the expected amount you would be paid back if you played the game?
Suppose \(X\sim\text{U}(0, 10)\) and \(Y = X^2\). Compute \(E[X]\) and \(E[Y]\).
(Dekking et al. Section 7.3)
\(E[Y]\neq \left(E[X]\right)^2\)
\(\int_0^{100} \frac{\sqrt{y}}{20} dy=\int_0^{10} x^2 \cdot \frac{1}{10}dx\)
\[E[Y]\neq \left(E[X]\right)^2\]
Alternatively, you can compute using
\[E[Y]=E\left[X^2\right]=\int_{-\infty}^\infty x^2 f_X(x) dx\]
The property implies that
Let \(X\) be a random variable, and let \(g:\mathbb{R}\to\mathbb{R}\) be a function. The change-of-variable formula states that
\[E\left[g\left(X\right)\right]=\sum_{i}g\left(a_i\right)P\left(X=a_i\right)\]
if \(X\) is discrete taking values \(a_1, a_2, \ldots,\); and
\[E\left[g\left(X\right)\right]=\int_{-\infty}^\infty g(x)f(x) dx\]
if \(X\) is continuous with probability density function \(f\).
Expectation of any symmetric distribution is the point of symmetry.
e.g., If \(X\sim N(\mu,\sigma^2)\), then \(E(X)=\mu\).
Expectation of a constant is the constant. That is, there is no randomness.
e.g., \(E\left[E\left(X\right)\right]\) for any random variable \(X\) is \(E(X)\).
When \(x=0\), \(x\frac{4^x}{x!}=0\).
Taylor Series expansion for \(e^u=\sum_{t=0}^\infty \left.u^t\right/t!\).
In general,
\[E[D]=\lambda\]
when \(D\sim\text{Pois}(\lambda)\).
We defined \(\lambda\) to be the expected rate of event in our construction of the Poisson distribution.
\(\text{Var}(X) \ge 0\) for any (random) variable.
\(\text{Var}(X) = 0\) implies no variability and \(X\) is a constant.
The variance \(\text{Var}(X)\) of a random variable \(X\) is the number defined by
\[\text{Var}(X)=E\left[\left(X-E\left[X\right]\right)^2\right].\]
Recall Michael drinks \(Y\) cups of coffee
per day with the pmf, \(p_Y\), shown below.
Compute \(\text{Var}(Y)\).
Recall Michael drinks \(Y\) cups of coffee
per day with the pmf, \(p_Y\), shown below.
Compute \(\text{Var}(Y)\).
\(E\left(rX+ s\right)=r E\left(X\right) + s\) where \(r\) and \(s\) are constants.
\[\text{Var}(X)\] \[=E\left[X^2\right]-E[X]^2\]
for any random variable \(X\).
All you need is \(E(X^2)\text{ & }E(X)\) to compute the variance.
Let’s check with \(Y\), Michael’s daily coffee consumption in cups.
\(\text{Var}(Y)=E\left[\left(Y-E[Y]\right)^2\right]\approx6.556\)
Variance of a constant is zero.
i.e., \(\text{Var}(a)=E\left[a^2\right] - \left(E\left[a\right]\right)^2\)
\(=a^2 - a^2 = 0\).
For any random variable \(X\), and constants \(r\) and \(s\),
\[\text{Var}(rX + s)=r^2\text{Var}(X)\]
\(\text{sd}(X)\) is another measure of variability.
You need \(\text{Var}(X)\) to compute standard deviation.
\(\text{sd}(X)\) is in the same unit as the random variable.
The standard deviation \(\text{sd}(X)\) of a random variable \(X\) is the number defined by
\[\text{sd}(X)=\sqrt{\text{Var}\left(X\right)}.\]
learnr
and run R worksheetClick here to install learnr
on r.datatools.utoronto.ca
Follow this link to open the worksheet
If you seen an error, try:
rlesson05
from Files paneOther steps you may try:
.Rmd
and .R
files on the home directory of r.datatools.utoronto.caTools
> Global Options
install.packages("learnr")
in RStudio after the steps above or click hereChapter 7, Dekking et al.
Quick Exercises 7.1, 7.2, and 7.4
Read Remark 7.1 (page 92)
All exercises from the chapter
See a collection of corrections by the author here
© 2023. Michael J. Moon. University of Toronto.
Sharing, posting, selling, or using this material outside of your personal use in this course is NOT permitted under any circumstances.