got from raf at recurse-center.

generalization of weighted average.

so:

in a case for a coin flip where if you get heads you win 10, and if you get tails you lose 0,

the expected value is 5.

10 * 0.5 + 0 * 0.5 = 5; 
 
so: 
 
E(X) = x1 * p(x1) + x2 * (px2) ..