-
Notifications
You must be signed in to change notification settings - Fork 54
/
Probability.html
338 lines (293 loc) · 9.33 KB
/
Probability.html
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<html>
<!-- THIS FILE WAS GENERATED BY A SCRIPT: DO NOT EDIT IT! -->
<head>
<link href="style.css" rel="stylesheet" type="text/css"/>
<title>
Probability Basics
</title>
</head>
<body>
<div id="header">
<div id="logo">
<img src="graphics/Julia.png">
</div>
<div id="user-tools">
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="feedback.html">Feedback</a>
</div>
</div>
<h1>Probability Basics</h1>
<center>
<img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/6sided_dice.jpg/300px-6sided_dice.jpg">
</center>
<br>
<p>
We assume that everyone is familiar with the basic concept of
probability (do not want to be very formal):
what an EVENT is and what
Prob(EVENT) is. For example: We are using a fair die. The usual,
with six sides and numbers 1, 2, 3,
4, 5, 6 on its sides. We throw it
once. Then the probability of the event A:"4 came out" is 1/6. The
probability of the event B:"5 came out"
is 1/6. The probability of the
event C:"an even number came out" is 1/2. Etc.
</p>
<h2>
Very basic rules/laws/definitions of probability:
</h2>
<p>
<br>
For any two events A, B:
<br>
<em>
Prob(A or B) = Prob(A) + Prob(B) - Prob(A and B)
</em>
<br>
<br>
["inclusion-exclusion"]
<br>
<br>
From this comes a crude way to estimate probabilities:
<em>
Prob(A or B) ≤ Prob(A) + Prob(B)
</em>
or more generally:
<br>
<br>
<em>
Prob(A<sub>1</sub> or A<sub>2</sub> or ... or A<sub>n</sub>)
≤ sum Prob (A<sub>i</sub>)
</em>
<br>
<br>
Two events A, B are <em>mutually exclusive</em> if
<em>
Prob(A and B) = 0.
</em>
<br>
<br>
Two events are <em>independent</em> if
<em>
Prob(A and B) = Prob(A) * Prob(B).
</em>
<br>
</p>
<h3>
Expectations ( =expected values ):
</h3>
<p>
<img
src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Beta_first_moment.svg/308px-Beta_first_moment.svg.png">
<br>
Expected value of a real variable <em>X</em> is defined as
<br>
<br>
<img
src="graphics/Lec3Eq6.gif">
<br>
<br>
where the sum is taken over all values <em>x</em> that <em>X</em> can take.
<br>
In words:
<br>
the expected value of a variable is the weighted sum of
all its
values, weighted according to the probability that they
happen.
<br>
<br>
Example: You throw a die and get $10 if it comes out 1 and
$0 if not.
<br>
<br>
The expected value of your reward is $10 * 1/6 + $0
* 5/6 = $10/6.
<br>
<br>
You play the lottery. You pay $1 for the ticket and win
one million
dollars with probability 1/(1 billion). How much do you
expect to
win? What's the expected balance?
<br>
<br>
Expected outcome = -$1 + Expected win.
<br>
<br>
Expected win = $1,000,000 * 1/(1 billion) + $0 * (the
probability I do not win) = $1/1000 = 0.1cent.
<br>
<br>
So expected outcome = you lose 99.9 cents.
<br>
<br>
</p>
<h4>
Useful properties of expectations:
</h4>
<p>
Linearity of expectation:
<br>
<br>
<em>
E[a X + b Y] = a E[X] + b E[Y]
</em>
<br>
<br>
for any two events X, Y
[there are some mild requirements on X and Y, but INDEPENDENCE IS NOT REQIURED!]
and constants a, b.
<br>
</p>
<h3>
Indicator variables:
</h3>
<p>
<img
src="https://upload.wikimedia.org/wikipedia/commons/2/20/Ancova_graph.jpg"
height="360" width="360"
>
<br>
X is an <em>indicator variable</em> for an event A if
<br>
<br>
X = 1 if A happens
X = 0 if A does not happen
<br>
<br>
Useful properties of indicator variables:
<br>
<br>
If X is an indicator variable for A, then
<em>
Exp[X]=Prob[X=1]=Prob[A happens]
</em>
.
<br>
This easily follows from the definition:
<br>
<em>
Exp[X]=1 * Prob[X=1] + 0 * Prob[X=0]=Prob[X=1]=Prob[A happens]
</em>
<br>
<br>
<a id="dice">Example</a>:
<br>
<br>
We throw a fair die 100 times What is the expected number
of times we get 1 or 6?
<br>
<br>
Let X<sub>i</sub> be the indicator
variable of the event "in i<sub>th</sub>
throw we got 1 or 6".
Then notice that the number of times we get 1 or 6 is
exactly
<br>
<br>
<img src="graphics/Lec3Eq1.gif">
<br>
<br>
and we want the expectation of this.
By linearity of expectations:
<br>
<br>
<img src="graphics/Lec3Eq2.gif">
<br>
<br>
and by the indicator variable properties:
<br>
<br>
<img src="graphics/Lec3Eq3.gif">
<br>
<br>
To summarize:
<br>
<br>
<img src="graphics/Lec3Eq4.gif">
<br>
<br>
So we expect to get 1 or 6 about 33.33 times.
</p>
<h3>How Many Roads Must One Man Walk?</h3>
<p>
Finally, something that comes up very frequently:
<br>
<br>
Suppose you have a sequence of events, each of which
happens with
probability p, independent of the previous ones. What is
the expected
number of tries in the sequence you must observe until you
see an event you like.
<br>
<br>
<b>Examples:</b>
<br>
<br>
Flip a coin several times. How many tries until it comes
out heads.
<br>
<br>
Throw a pair of die. How many tries until they give you
{6,6}?
<br>
<br>
Play the lottery. How many tries until you win?
<br>
<br>
Probability event i happens is
<em>
(1 - p)<sup>i - 1</sup>p
</em>
In this case you need to
wait i steps. So the expected number of steps to wait is:
<br>
<br>
<img src="graphics/Lec3Eq5.gif">
<br>
<br>
It's a standard summation that adds up to 1/p. [A cute or
painful algebra exercise, depending on how you do it, I guess...]
<br>
<br>
so:
<br>
<br>
Fact: If you have a sequence of independent events, each
succeeding
with probability p, the expected number of tries until the
first
success is 1/p.
<br>
<br>
Or slightly more generally:
<br>
<br>
Fact: If you have a sequence of independent events, each
succeeding
with probability at least p, the expected number of tries
until the
first success is at most 1/p.
<br>
<br>
[The last one is useful if you are doing sampling without
replacement, so the probabilities changes as you go along.]
<br>
<br>
</p>
</body>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-97026578-2', 'auto');
ga('send', 'pageview');
</script>
</html>