Is it possible to calculate the expectation of a function of a random variable with only the the r.v.'s CDF? Say I have a function $g(x)$ that has the property $\int_{-\infty}^{\infty}g(x)dx \leq \infty $ and the only information I have about the random variable is the CDF.

For example, I have a scenario where there are three timers that can be modeled as exponential random variables $X_1,X_2,X_3$ with rate parameters $\lambda_1,\lambda_2,\lambda_3$ respectively. For each moment in time I earn a reward according to some reward function $g(x)$. That is, my reward for waiting until time $t$ can be written as $\int_0^tg(x)dx$. However, $g(x)$ experiences diminishing returns so the the marginal reward received from waiting one second at $t=0$ is greater than one second at say $t=27$. This 'game' ends when one of two things happens. Either both timers $X_1$ or $X_2$ must ring or timers $X_1$ or $X_3$ must ring. I'm trying to find the expected reward of playing this game.

Currently I can calculate the the CDF of the random variable modeling the time until the game ends, but I dont know how to use this information to when what I really need is reward associated with this time.

So far I have the additional random variables: $$ W_{12}=\max(X_1,X_2) \quad W_{13}=\max(X_1,X_3) \quad Z=\min(W_{12},W_{13})$$ Also let $F_i(x), i\in \{1,2,3\}$ denote the CDF of $X_i$ The CDF of $Z$, can be written as: $$F_Z(t) = F_1(t)F_2(t) + F_1(t)F_3(t) - F_1(t)F_2(t)F_3(t)$$

I know when a random variable takes on non-negative values, you can use a shortcut to calculate the expectation using the CDF. That is, $E[X] = \int_0^\infty F(X\geq x)dx$. Is there something similar I could use for a function of a random variable, or is it necessary to compute the pdf of $Z$ first to compute $\int_0^\infty g(t)f_z(t)dx$

  • 4
    $\begingroup$ What do you mean by "only" information? The CDF tells you everything about the RV that might be related to expectations! It seems like your underlying issue might have to do with the computational form in which the CDF is given to you. Please explain your circumstances. BTW, $E[g(X)]$ can be undefined or infinite even when the integral of $|g|$ is finite. $\endgroup$
    – whuber
    Commented Jul 6, 2016 at 18:25
  • 2
    $\begingroup$ I think you are looking for integration by parts en.wikipedia.org/wiki/Integration_by_parts $\endgroup$
    – seanv507
    Commented Jul 6, 2016 at 18:56

1 Answer 1


When $F$ is the CDF of a random variable $X$ and $g$ is a (measurable) function, the expectation of $g(X)$ can be found as a Riemann-Stieltjes integral

$$\mathbb{E}(g(X)) = \int_{-\infty}^\infty g(x) dF(x).$$

This expresses the Law of the Unconscious Statistician.

If $g$ is also differentiable, write $dF = -d(1-F)$ and integrate by parts to give

$$\mathbb{E}(g(X)) = -g(x)(1-F(x)){\big|}_{-\infty}^\infty + \int_{-\infty}^\infty (1-F(x)) g^\prime(x)\, \text{d}x$$

provided both addends converge. This means several things, which may be simply expressed by breaking the integral at some definite finite value such as $0$:

  1. ${\lim}_{x\to -\infty} g(x)(1-F(x))$ and ${\lim}_{x\to \infty} g(x)(1-F(x))$ exist and are finite. If so, the first addend is the difference of these two.

  2. $\lim_{t\to -\infty} \int_t^0 (1-F(x))g^\prime(x)\,\text{d}x$ and $\lim_{t\to \infty} \int_0^t (1-F(x))g^\prime(x)\,\text{d}x$ exist and are finite. If so, the second addend is the sum of these two.

A good place to break the integral is at any zero of $g$, because--provided $g$ eventually decreases fast enough for large $|x|$--that causes the first addend to vanish, leaving only the integral of $g^\prime$ against the survival function $1-F$.


The expectation of a non-negative variable $X$ is obtained by applying the formula to the identity function $g(x)=x$ for which $g^\prime(x)=1$ and utilizing the fact that the integration may begin at zero:

$$\mathbb{E}(X) = -x(1-F(x))\big|_{0}^\infty + \int_{0}^\infty (1-F(x))\,\text{d}x.$$

Provided $\lim_{x\to\infty} x (1-F(x)) = 0$ (that is, the survival function does not have an overly heavy tail), the upper limit of the first term vanishes. Its lower limit obviously vanishes. We are left only with the integral, giving the expression in the question.

  • 1
    $\begingroup$ This uses three basic rules of differentiation: the sum rule, the product rule, and the fact that constants have zero derivatives. $\endgroup$
    – whuber
    Commented Jul 11, 2016 at 15:14
  • 2
    $\begingroup$ @Dave Why does that matter? For a variable with a lower bound, you get a boundary term, so include it. For a variable with no lower bound, sum the contributions from its positive part and negative part separately. Indeed, the same method works for any variable. Thus, $E[X]=\int_0^\infty (1-F(x))dx - \int_{-\infty}^0 F(x) dx$ whenever the expectation exists. This seems not even worth discussing, because all we're debating is how one goes about evaluating an integral via integration by parts. That's scarcely controversial. $\endgroup$
    – whuber
    Commented Sep 27, 2017 at 20:36
  • 1
    $\begingroup$ @ablmf Consult any account of integration by parts. $\endgroup$
    – whuber
    Commented Jul 12, 2019 at 11:49
  • 1
    $\begingroup$ Dang, this almost solved a problem for me save that in my case $g$ is non-smooth and has an image which is just the finite set $\{ -1, 0, 1 \}$. But +1 anyway cause this is a great answer. $\endgroup$
    – Galen
    Commented Feb 27, 2023 at 5:23
  • 2
    $\begingroup$ @galen When $g$ is not smooth at discrete points, you can break up the integral at those points and proceed in exactly the same way. Integration by parts will potentially introduce some additive terms related to values of $g$ at those points. $\endgroup$
    – whuber
    Commented Feb 27, 2023 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.