Skip to main content
edited tags
Link
amoeba
  • 107.3k
  • 36
  • 321
  • 347
Tweeted twitter.com/#!/StackStats/status/136584345552044032
Source Link
Tyler Streeter
  • 1.1k
  • 1
  • 10
  • 22

Does a univariate random variable's mean always equal the integral of its quantile function?

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.