Project 33: Mean of Discrete Random Variable

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 33: 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, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0