Welcome to this Sandbox page, which allows you to carry out experiments. To edit, clickor the Edit tab above; make your changes, and click the Save page button when finished.
Suppose random variable X can take value x1 with probability p1, value x2 with probability p2, and so on, up to value xk with probability pk. Then the expectation of this random variable X is defined as
Since all probabilities pi add up to one: p1 + p2 + ... + pk = 1, the expected value can be viewed as the weighted average, with pi’s being the weights: