Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
263 lines (249 sloc) 12.1 KB
 Expected value
randFromArray([ ["a <code>1</code>", 1], ["a <code>2</code>", 1], ["a <code>3</code>", 1], ["a <code>4</code>", 1], ["a <code>5</code>", 1], ["a <code>6</code>", 1], ["a <code>7</code>", 1], ["an <code>8</code>", 1], ["a <code>9</code>", 1], ["a <code>10</code>", 1], ["at least a <code>2</code>", 9], ["at least a <code>5</code>", 6], ["at least a <code>7</code>", 4], ["more than a <code>2</code>", 8], ["more than a <code>6</code>", 4], ["more than an <code>8</code>", 2], ["less than a <code>4</code>", 3], ["less than a <code>7</code>", 6], ["less than an <code>8</code>", 7], ["an even number", 5], ["an even number", 5], ["an odd number", 5], ["an odd number", 5] ]) 10 - MAKE_COUNT fraction(MAKE_COUNT, 10, true, false) fraction(LOSE_COUNT, 10, true, false) randRange(5, 10) randRange(5, 10) MAKE_COUNT * MAKE - LOSE_COUNT * LOSE fraction(PROFIT, 10, true, false) PROFIT / 10

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). randFromArray([4,6,10,12]) (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("+"); })() _.reduce(_.range(SIDES), function(n,i){ return n+i+1; }, 0) If you roll a SIDES-sided die, what is the expected value you will roll? ANS_N/SIDES 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). random() < 0.4 randRange(2,5) randRange(1,5)*100 BUY ? COST*ODDS + randRange(1,3)*100 : COST*ODDS - randRange(1,3)*100 fraction(1,ODDS,true,true) BUY ? "Yes, the expected value is positive." : "No, the expected value is negative." 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? ANS • Yes, the expected value is positive. • No, the expected value is negative. 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.