# Expectation of a function of a continuous random variable

#### kingwinner

If W=g(X) is a function of continuous random variable X, then E(W)=E[g(X)]=

∫g(x) [fX(x)] dx
-∞
============================
Even though X is continuous, g(X) might not be continuous.

If W happens to be a discrete random variable, does the above still hold? Do we still integrate ∫ (instead of sum ∑)?

Does it matter whether W itself is discrete or continuous?

Thanks!

Related Set Theory, Logic, Probability, Statistics News on Phys.org

#### jambaugh

Science Advisor
Gold Member
If the variable is discrete you can still express in terms of integrals using dirac delta functions though it is simpler to replace the integral with a sum over values.

#### jason1995

If W=g(X) is a function of continuous random variable X, then E(W)=E[g(X)]=

∫g(x) [fX(x)] dx
-∞
============================
Even though X is continuous, g(X) might not be continuous.

If W happens to be a discrete random variable, does the above still hold?
Yes. Consider the simplest case, where g(x) = 1 if x is in [a,b] and 0 otherwise. Then

\begin{align*} E[W] &= 1\cdot P(W = 1) + 0\cdot P(W = 0)\\ &= P(g(X) = 1)\\ &= P(X\in [a,b])\\ &= \int_a^b f_X(x)\,dx. \end{align*}

On the other hand, the formula also gives

$$\int_{-\infty}^\infty g(x)f_X(x)\,dx = \int_a^b f_X(x)\,dx.$$

#### gkannan16

Go for summations.....that will solve ur problem and rest all may complicate

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving