Calculate mean of discrete random variable (#843)