For a game at the carnival you get to roll a ten-sided die, numbered from 1
to 10
.
If you roll RESULT_DESC, you win $MAKE
.
Unfortunately, if you roll anything else, you lose $LOSE
.
How much money do you expect to make (or lose) per game?
$
ANS
The expected value is a weighted average of the possible values with the weights determined by the probability of observing that value.
There are two events that can happen in this game: either
you roll RESULT_DESC, or you don't. So, the
expected value will look like this:
E =
(money gained when you roll RESULT_DESC)
\cdot
(probability of rolling RESULT_DESC)
+
(money gained when you don't roll RESULT_DESC)
\cdot
(probability of not rolling RESULT_DESC).
The money you gain when you win is $MAKE
.
The probability of winning is the probability
that you roll RESULT_DESC.
This probability is the number of winning outcomes
divided by the total number of
outcomes, MAKE_FR
.
The money you gain when you lose is -$LOSE
(since you actually lose money). The probability that
you lose is the probability that you don't roll
RESULT_DESC.
This probability must be
1 - MAKE_FR = LOSE_FR
.
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:
(MAKE\cdotMAKE_FR) +
(-LOSE\cdotLOSE_FR) =
ANS_F = -$localeToFixed(-ANS, 2)
$localeToFixed(ANS, 2).
If you roll a SIDES-sided die, what is the expected value you will roll?
The expected value is a weighted average of the possible values with the weights determined by the probability of observing that value.
In this case, there are SIDES 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.
So, the value of the first outcome is 1, and its
probability is \dfrac{1}{SIDES}
.
The value of the second outcome is 2, the value of
the third outcome is 3, and so on. There are
SIDES outcomes altogether, and each of them
occurs with probability
\dfrac{1}{SIDES}
.
So, if we average the values of each of these outcomes,
we get the expected value we will roll, which is
SUM =
mixedFractionFromImproper(ANS_N,SIDES,true,true)
.
You decide you're only going to buy a lottery ticket if your
expected winnings are larger than the ticket price. Tickets
cost $COST
, and you get
$PRIZE
if you win. The odds of
winning are 1
in ODDS
,
meaning that you will win with probability
ODD_F
.
Should you buy a ticket for this lottery?
The expected value is a weighted average of the possible values with the weights determined by the probability of observing that value.
This means the expected value, considering both the price
of the ticket and the possible winnings is
E =
(money gained when you win)
\cdot
(probability of winning) +
(money gained when you lose)
\cdot
(probability of losing).
Let's figure out each of these terms one at a time. The
money you gain when you win is
$PRIZE
and from the question, we
know the probability of winning is
ODD_F
.
When you lose, you gain no money, or
$0
, and the probability of losing is 1
- ODD_F
.
Putting it all together, the expected value is
E = ($PRIZE)
(ODD_F) + ($0) (1 - ODD_F) =
$ \dfrac{PRIZE}{ODDS} =
$fraction(PRIZE,ODDS,true,true)
.
$fraction(PRIZE,ODDS,true,true) -
$COST
is positive.
So, we expect to make money by buying a lottery ticket, because
the expected value is positive.
$fraction(PRIZE,ODDS,true,true) -
$COST
is negative.
So, we expect to lose money by buying a lottery ticket, because
the expected value is negative.