/
lecture_2.tex
214 lines (157 loc) · 5.72 KB
/
lecture_2.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
\documentclass{article}
\usepackage{teaching, array}
\begin{document}
\begin{tdoc}{CHEM 116}{Unit 4, Lecture 2}{Numerical Methods and Statistics}
\subsection*{Companion Reading}
\textbf{Bulmer} Chapter 5
\section{Expected Values}
The expected value of a samlpe $x$ is
\begin{equation}
\pexp{X} = \sum_\mathcal{Q} P(X=x)x
\end{equation}
An expected value is analagous to a mean, except you don't add data
points. You add the elements in your sample space, weighted by their
probability. Be careful not to be confused: the expected value is not
the most likely outcome. The most likely outcome is the $x$ which
maximizes $P(x)$, written as:
\begin{equation}
\argmax_x P(x)
\end{equation}
Think of an expected value as a measure of the center point of the sample space.
\subsection{Die Roll Example}
Consider a fair die example, where $d$ is an element in our sample
space. Our sample space is one through six and the probability of a sample
occuring is $1/6$.
\[
\pexp{D} = \frac{1}{6}\times{}1 + \frac{1}{6}\times{}2 + \frac{1}{6}\times{}3 \ldots
\]
\[
\pexp{D} = \frac{1}{6}\times 21 = 3.5
\]
Notice that the expected value is NOT an element of the sample space.
\subsection{Unfair Die Example}
Now consider our unfair die, where
\[
P(D = d) = \frac{d}{21}
\]
so for example, the probability of rolling a 4 is $4/21$.
\[
\pexp{D} = \sum_{1,\ldots,6} \frac{d}{21} \times d = \frac{91}{21}
\]
\section{Expected Value of a Random Variable}
To calculate the expected value of a random variable $S$, use:
\begin{equation}
\pexp{S} = \sum_\mathcal{Q} P(X=x)S(x)
\end{equation}
Remember that the random variable $S$ is defined by some $S(x)$
function, whose input is an element in the sample space and has an
output of some real number.
\subsection{Expected Value for Sum of 2 Dice}
Consider the product sample space of two dice: $Q_2 = Q \otimes Q$,
where $Q$ is $1,\ldots,6$. Example of elements of this sample space
are rolling a 2 for the first die and a 4 for the second die: $(2,
4)$. There are 36 elements in the sample space and we'll take the
probability of each to be equivalent. This gives:
\[
P(X = x) = P(X = (x_1, x_2)) = \frac{1}{36}
\]
Define $S$ as our random variable representing the sum of the two dice.
\[
S(x) = S(\, (x_1, x_2)\, ) = x_1 + x_2
\]
Now we can plug these into our expected value equation:
\[
\pexp{S} = \sum_{Q} P(X=x)S(x) = \sum_{(x_1,x_2) \in Q_2} \frac{1}{36} S( (x_1, x_2) )
\]
\[
= \frac{1}{36}\times (1 + 1) + \frac{1}{36} \times (1 + 2) + \frac{1}{36} \times (1 + 3) + \ldots + \frac{1}{36} \times (6 + 6)
\]
To calculate the answer, we need to sum all 36 possible dice rolls
together. That turns out to be 252. So we have:
\[
\pexp{S} = \frac{252}{36} = 7
\]
\subsection{Expected Value for Sum of 2 Dice - Alternate}
Another way to solve this problem is to DEFINE our sample space to be
the possible sums. Then $Q = \{2, 3, \ldots, 12\}$. Our correponding
probability is going to be the number of permutations to roll the sum
divided by some normalizing constant. For example, the probability of
rolling a 6 is 5 / Z, where $Z$ is some constant to make sure our
probabilities sum to 1. The 5 comes from the number of ways to roll a
6: $(1, 5), (2, 4), (3, 3), (4, 2), (5, 1)$. I'm calling these permutations because $(1,5)$ and $(5,1)$ are both counted. Now we to find $Z$:
\[
Z = \underbrace{1}_{\textrm{permutations to roll a 2}} + \underbrace{2}_{\textrm{permutations to roll a 3}},\, \ldots\,, \underbrace{1}_{\textrm{permutations to roll a 12}}
\]
\[
Z = \underbrace{1}_2 + \underbrace{2}_3 + \underbrace{3}_4 + \underbrace{4}_5 + \underbrace{5}_6 + \underbrace{6}_7 + \underbrace{5}_8 + \underbrace{4}_9 + \underbrace{3}_{10} + \underbrace{2}_{11} + \underbrace{1}_{12} = 36
\]
where the underbraces indicate which dice roll sum each term corresponds
to. Doing this work also reveals an equation for the probability:
\[
P(S = s) = \frac{6 - |s - 7|}{36}
\]
Finally, we are ready to utilize the expected value equation:
\[
\pexp{S} = \sum_\mathcal{Q} P(S=s)s = \sum_{2,\ldots,12} \frac{6 - |s - 7|}{36}\times s
\]
\[
= \frac{1 \times 2}{36} + \frac{2 \times 3}{36} + \frac{3 \times 4}{36} + \ldots + \frac{1 \times 12}{36}
\]
\[
= \frac{252}{36} = 7
\]
Thus we've arrived at the same answer.
\subsection{Continuous Expected Value}
\begin{equation}
\pexp{X} = \int_\mathcal{X}\,xp(x)\,dx
\end{equation}
\subsection{Continuous Example}
\[
p'(x) \propto x,\: Q = [0,5]
\]
First, we must normalize it:
\[
\int_0^5 \,x\,dx = \frac{25}{2}
\]
\[
p(x) = \frac{2x}{25}
\]
\[
\int_0^5 x\times\frac{2x}{25} = \frac{2\times 125}{25\times 3} = \frac{10}{3}
\]
\subsection{Conditional Expectation Value}
\begin{equation}
\Econd{X}{Y=y} = \sum_\mathcal{X} \Pcond{X=x}{Y=y}x
\end{equation}
\subsection{Die Roll Example}
Our random variable $X$ is the observation, and $Y = 0$ if the observation is odd and $Y = 1$ if the observation is even.
\[
\Econd{X}{Y=0} = \frac{1}{3}\times{}1 + \frac{1}{3}\times{}3 + \frac{1}{3}\times{}5 = 3
\]
Expected value gives the center of a random variable or probability
distribution.
\section{Variance}
Variance gives the average deviation from that
center. To make sure variation above and below the center contributes,
it is the expected squared distance from the expected value:
\begin{equation}
\var(X) = \pexp{(\pexp{X} - X)^2} = \pexp{X^2} - \pexp{X}^2
\end{equation}
\subsection{Die Roll Example}
We already know $\pexp{X} = 21/6 = 3.5$. To find $\pexp{D^2}$, we can use our
random variable expectation equation. Take $F$ to be our random
variable deinfed by $F(x) = x^2$:
\[
\pexp{D^2} = \pexp{F} = \sum_Q P(x)x^2 =
\]
\[
= \frac{1}{6}\times{}1^2 + \frac{1}{6}\times{}2^2 + \frac{1}{6}\times{}3^2 \ldots
\]
\[
= \frac{91}{6}
\]
\[
\var(D) = \frac{91}{6} - \frac{21^2}{6^2} = \frac{35}{12} = 2.92
\]
\end{tdoc}
\end{document}