Project 32: Expected Value

Intro Problem: Suppose a game of chance costs $13 to play.  However, you get paid X dollars after you play the game.  The probability distribution for how much money (X) is paid back.


What is the mean (average) amount of money you would win back (not profit) from playing the game?

For the distribution below, there is a 10% chance that X is 5, a 20% chance that X is 10, a 30% chance that X is 15, and a 40% chance that X is 20.  The calculations are shown below that the mean (or the expected value) for X is 15.

Project 32: Variables x and pX have been initialized.  

x is an array that represents the possible values for x ([5, 10, 15, 20] in the example above).

pX is an array that represents the probability of the corresponding value of x ([.1, .2, .3, .4] in the example above).

Task: Appropriately initialize the value for the variable 'mean' that represents the mean for x.

**If your code works for 5 test cases in a row, you can enter your e-mail address.