This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 863
/
expected_value.html
292 lines (279 loc) · 12.7 KB
/
expected_value.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
<!DOCTYPE html>
<html data-require="math word-problems math-format">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Expected Value</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<div class="exercise">
<div class="problems">
<div id="game" data-weight="2">
<div class="vars">
<var id="RESULT_DESC, MAKE_COUNT">randFromArray([
["a 1", 1],
["a 2", 1],
["a 3", 1],
["a 4", 1],
["a 5", 1],
["a 6", 1],
["a 7", 1],
["an 8", 1],
["a 9", 1],
["a 10", 1],
["at least a 2", 9],
["at least a 5", 6],
["at least a 7", 4],
["more than a 2", 8],
["more than a 6", 4],
["more than an 8", 2],
["less than a 4", 3],
["less than a 7", 6],
["less than an 8", 7],
["an even number", 5],
["an even number", 5],
["an odd number", 5],
["an odd number", 5]
])</var>
<var id="LOSE_COUNT">10 - MAKE_COUNT</var>
<var id="MAKE_FR">fraction(MAKE_COUNT,10,true,false)</var>
<var id="LOSE_FR">fraction(LOSE_COUNT,10,true,false)</var>
<var id="MAKE">randRange(5,10)</var>
<var id="LOSE">randRange(5,10)</var>
<var id="PROFIT">MAKE_COUNT*MAKE - LOSE_COUNT*LOSE</var>
<var id="ANS_F,ANS">
[fraction(PROFIT,10,true,false),
(PROFIT/10).toFixed(2)]
</var>
</div>
<p>
A game at the carnival offers these odds: you get to roll a
ten-sided die, and if you roll <var>RESULT_DESC</var>,
you make <code><var>MAKE</var></code> dollars. Unfortunately,
if you roll anything else, you lose
<code><var>LOSE</var></code> dollars.
</p>
<p class="question">
How much money do you expect to make (or lose)
playing this game?
</p>
<div class="solution" data-type="multiple">
<code>$</code>
<span class="sol" data-forms="integer, decimal"><var>ANS</var></span>
</div>
<div class="hints">
<p>
The expected value of an event (like playing this game)
is the average of the values of each outcome. Since some
outcomes are more likely than others (sometimes), we
weight the value of each outcome according to its
probability to get an accurate idea of what value
to expect.
</p>
<p>
There are two events that can happen in this game: either
you roll <var>RESULT_DESC</var>, or you don't. So, the
expected value will look like this:
</br></br>
<code>E = </code>
(money gained when you roll <var>RESULT_DESC</var>)
<code>\cdot</code>
(probability of rolling <var>RESULT_DESC</var>)
<code>+</code>
(money gained when you don't roll <var>RESULT_DESC</var>)
<code>\cdot</code>
(probability of not rolling <var>RESULT_DESC</var>).
</p>
<p>
The money you gain when you win
is <code>$<var>MAKE</var></code>.
The probability of winning is the probability
that you roll <var>RESULT_DESC</var>.
</p>
<p>
This probability is the number of winning outcomes
divided by the total number of
outcomes, <code><var>MAKE_FR</var></code>.
</p>
<p>
The money you gain when you lose is
<code>$ -<var>LOSE</var></code>
(since you actually lose money). The probability that
you lose is the probability that you don't roll
<var>RESULT_DESC</var>.
</p>
<p>
This probability must be
<code>1 - <var>MAKE_FR</var> = <var>LOSE_FR</var></code>.
</p>
<p>
So, if we take the average of the amount of money you make
on each outcome, weighted by how probable each outcome is,
we get the expected amount of money you will make:
<code>(<var>MAKE</var>\cdot<var>MAKE_FR</var>) +
(-<var>LOSE</var>\cdot<var>LOSE_FR</var>) =
$<var>ANS_F</var> = $<var>ANS</var>.
</code>
</p>
</div>
</div>
<div id="die" data-weight="1">
<div class="vars">
<var id="SIDES">randFromArray([4,6,10,12])</var>
<var id="SUM">
(function(){
if(SIDES < 7) {
return _.map(_.range(SIDES), function(i){
return "\\dfrac{"+(i+1)+"}{"+SIDES+"}"; })
.join("+");
}
first = _.map(_.range(3), function(i){
return "\\dfrac{"+(i+1)+"}{"+SIDES+"}"; })
.join("+");
last = _.map(_.range(3), function(i){
return "\\dfrac{"+(SIDES-2+i)+"}{"+SIDES+"}"; }).join("+");
return [first,"\\cdots",last].join("+");
})()
</var>
<var id="ANS_N">
_.reduce(_.range(SIDES), function(n,i){ return n+i+1; }, 0)
</var>
</div>
<p class="question">
If you roll a <var>SIDES</var>-sided die, what is the expected
value you will roll?
</p>
<div class="solution" data-forms="mixed, improper, decimal">
<var>ANS_N/SIDES</var>
</div>
<div class="hints">
<p>
The expected value of an event (like rolling a die)
is the average of the values of each outcome. To get an
accurate idea of what value to expect, we
weight the value of each outcome according to its
probability.
</p>
<p>
In this case, there are <var>SIDES</var> outcomes:
the first outcome is rolling a 1, the second outcome is
rolling a 2, and so on. The value of each of these outcomes
is just the number you roll.
</p>
<p>
So, the value of the first outcome is 1, and its
probability is <code>\dfrac{1}{<var>SIDES</var>}</code>.
</p>
<p>
The value of the second outcome is 2, the value of
the third outcome is 3, and so on. There are
<var>SIDES</var> outcomes altogether, and each of them
occurs with probability
<code>\dfrac{1}{<var>SIDES</var>}</code>.
</p>
<p>
So, if we average the values of each of these outcomes,
we get the expected value we will roll, which is
<code><var>SUM</var> =
<var>mixedFractionFromImproper(ANS_N,SIDES,true,true)</var></code>.
</p>
</div>
</div>
<div id="lottery" data-weight="2">
<div class="vars">
<var id="BUY">random() < 0.4</var>
<var id="COST">randRange(2,4)</var>
<var id="ODDS">randRange(1,5)*100</var>
<var id="PRIZE">BUY ?
COST*ODDS + randRange(1,3)*100 :
COST*ODDS - randRange(1,3)*100
</var>
<var id="ODD_F">fraction(1,ODDS,true,true)</var>
<var id="ANS">BUY ?
"Yes, the expected value is positive." :
"No, the expected value is negative."
</var>
</div>
<p>
You decide you're only going to buy a lottery ticket if the
expected amount of money you will get is positive. Tickets
cost <code>$<var>COST</var></code>, and you get
<code>$<var>PRIZE</var></code> if you win. The probability
that you will win is <code><var>ODD_F</var></code>.
</p>
<p class="question">
Should you buy a ticket for this lottery?
</p>
<div class="solution">
<var>ANS</var>
</div>
<ul class="choices" data-category="true">
<li>Yes, the expected value is positive.</li>
<li>No, the expected value is negative.</li>
</ul>
<div class="hints">
<p>
The expected value of an event (like buying a lottery
ticket) is the average of the values of each outcome.
In this case, the outcome where you win is much less likely
than the outcome that you lose. So, to get an accurate idea
of how much money you expect to win or lose, we have to
take an average weighted by the probability of each outcome.
</p>
<p>
As an equation, this means the expected amount of money
you will win is
<code>E = </code> (money gained when you win)
<code>\cdot</code> (probability of winning) <code>+</code>
(money gained when you lose)
<code>\cdot</code> (probability of losing)
.
</p>
<p>
Let's figure out each of these terms one at a time. The
money you gain when you win is your winnings minus the
cost of the ticket, <code>$<var>PRIZE</var> -
$<var>COST</var></code> (you may find the math easier
if you <b>don't</b> simplify this).
</p>
<p>
From the question, we know the probability of winning is
<code><var>ODD_F</var></code>.
</p>
<p>
The money you gain when you lose is actually negative,
and is just the cost of the ticket,
<code>-$<var>COST</var></code>.
</p>
<p>
Finally, the probability of losing is <code>(1 -
<var>ODD_F</var>)</code> (you may find the math
easier if you <b>don't</b> simplify this).
</p>
<p>
Putting it all together, the expected value is
<code>E = ($<var>PRIZE</var> - $<var>COST</var>)
(<var>ODD_F</var>) + (-$<var>COST</var>)
(1 - <var>ODD_F</var>) = </code>
<code> $ \dfrac{<var>PRIZE</var>}
{<var>ODDS</var>} - $ \cancel{\dfrac{<var>COST</var>}
{<var>ODDS</var>}} - $<var>COST</var> +
$ \cancel{\dfrac{<var>COST</var>}{<var>ODDS</var>}} =
$<var>fraction(PRIZE,ODDS,true,true)</var> -
$<var>COST</var></code>.
</p>
<p>
<code>$<var>fraction(PRIZE,ODDS,true,true)</var> -
$<var>COST</var></code> is
<var>PRIZE/ODDS - COST > 0 ? "positive" : "negative"</var>.
</br></br>
So, we expect to <var>PRIZE/ODDS - COST > 0 ? "make" : "lose"</var> money by buying a lottery ticket, because
the expected value is <var>PRIZE/ODDS - COST > 0 ?
"positive" : "negative"</var>.
</p>
</div>
</div>
</div>
</div>
</body>
</html>