If is a random variable with cdf then its mean (expected value) is given by
provided at least one of the two integrals is finite. This formula may be interpreted as the area of the region above the graph of and below for positive x minus the area of the region below the graph of (and above the x axis) for negative x. It also becomes intuitive by considering the Lebesgue-Stieltjes integral , in which the axis is subdivided.
To show this we first decompose into difference of its positive and negative parts: , where and . Then we may write each of these in terms of integrals of the following 0-1 indicator random variables (equal to 1 if the inequality holds, 0 otherwise).
Applying Fubini’s theorem on the positive functions and we swap integration and expectation and then use the fact that the expectation of an indicator random variable is the probability of the corresponding event occurring. We obtain
as required. The result may also be proved by integration by parts .
 Hajek, Notes for ECE 534: An Exploration of Random Processes for Engineers, July 2011, available here.