# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
295 lines (281 sloc) 12.8 KB
 Expected Value
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] ]) 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).toFixed(2)]

A game at the carnival offers these odds: you get to roll a ten-sided die, and if you roll RESULT_DESC, you make MAKE dollars. Unfortunately, if you roll anything else, you lose LOSE dollars.

How much money do you expect to make (or lose) playing this game?

$ANS 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. 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 = $ANS. 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 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. 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,4) 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 the expected amount of money you will get is positive. 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 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. As an equation, this means the expected amount of money you will win 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 your winnings minus the cost of the ticket,$PRIZE - $COST (you may find the math easier if you don't simplify this). From the question, we know the probability of winning is ODD_F. The money you gain when you lose is actually negative, and is just the cost of the ticket, -$COST.

Finally, the probability of losing is (1 - ODD_F) (you may find the math easier if you don't simplify this).

Putting it all together, the expected value is E = ($PRIZE -$COST) (ODD_F) + (-$COST) (1 - ODD_F) =$ \dfrac{PRIZE} {ODDS} - $\cancel{\dfrac{COST} {ODDS}} -$COST + $\cancel{\dfrac{COST}{ODDS}} =$fraction(PRIZE,ODDS,true,true) - $COST.$fraction(PRIZE,ODDS,true,true) - \$COST is PRIZE/ODDS - COST > 0 ? "positive" : "negative".

So, we expect to PRIZE/ODDS - COST > 0 ? "make" : "lose" money by buying a lottery ticket, because the expected value is PRIZE/ODDS - COST > 0 ? "positive" : "negative".

Something went wrong with that request. Please try again.