Calculate expected value for discrete random variable