Expectation of the function of a random variable