I just noticed that integrating a univariate random variable's quantile function (inverse cdf) from p=0 to p=1 produces the variable's mean. I haven't heard of this relationship before now, so I'm wondering: Is this always the case? If so, is this relationship widely known?
Here is an example in python:
from math import sqrt
from scipy.integrate import quad
from scipy.special import erfinv
def normalPdf(x, mu, sigma):
return 1.0 / sqrt(2.0 * pi * sigma**2.0) * exp(-(x - mu)**2.0 / (2.0 * sigma**2.0))
def normalQf(p, mu, sigma):
return mu + sigma * sqrt(2.0) * erfinv(2.0 * p - 1.0)
mu = 2.5
sigma = 1.3
quantileIntegral = quad(lambda p: quantile(p,mu,sigma), 0.0, 1.0)[0]
print quantileIntegral # Prints 2.5.