# Expectation of a function of a random variable from CDF

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$

• 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. – whuber Jul 6 '16 at 18:25
• I think you are looking for integration by parts en.wikipedia.org/wiki/Integration_by_parts – seanv507 Jul 6 '16 at 18:56

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$$.

### Example

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.

• Thanks, this looks exactly like I wanted. I just need to read up on my Riemann-Stieltjes integration now. – CoconutBandit Jul 6 '16 at 21:22
• In your application, because $F$ is continuously differentiable everywhere except at $0$, you can break the integral at $0$ into two Riemann integrals and ignore the complications altogether. – whuber Jul 6 '16 at 21:43
• What do you mean by 'complications'? Also, in your second point, should $\int_t^0(1-F(x))g(x)dx$ be $\int_t^0(1-F(x))g'(x)dx$? If not, why did the $g'(x)$ change to $g(x)$? – CoconutBandit Jul 7 '16 at 13:58
• (1) Thank you, those primes needed to be there. (2) "Complications" refers to needing the Riemann-Stieltjes integral instead of the Riemann integral. – whuber Jul 7 '16 at 14:01
• This uses three basic rules of differentiation: the sum rule, the product rule, and the fact that constants have zero derivatives. – whuber Jul 11 '16 at 15:14