Actuarial Statistics · Expectations and conditional expectations
Expectation of a Random Variable: Discrete, Continuous and E[g(X)]
Updated 11 October 2026 · Fact-checked
The expectation E[X] is the probability-weighted average value of X. For a discrete variable, E[X] = Σ x·P(X = x). For a continuous variable, E[X] = ∫ x·f(x) dx. For a function, E[g(X)] = Σ g(x)·P(X = x) or ∫ g(x)·f(x) dx. You do not need the distribution of g(X).
Understand Expectation of a Random Variable
The expected value of a random variable is its long-run average. If you repeat an experiment many times, the average of the results settles near E[X]. It is also called the mean, written μ.
For a discrete variable, list each value x and its probability. Multiply each pair and add. Each value is weighted by how likely it is. A likely value pulls the mean towards itself more than an unlikely one.
For a continuous variable, the sum becomes an integral. You multiply x by the density f(x) and integrate over the range where f is positive. The integral is the continuous version of weighting by probability.
Often you need the expectation of a function, such as a claim payment after a deductible, or X². The rule is simple: apply g to x inside the sum or integral, and keep the original probabilities or density. This is sometimes called the law of the unconscious statistician. You never need to find the distribution of g(X) first.
Note that E[g(X)] is generally not g(E[X]). For example, E[X²] is usually bigger than (E[X])². The gap is the variance. Also, the expectation may not exist if the sum or integral does not converge absolutely. The Cauchy distribution is the standard example.
Key rules to remember
- Expectation, discrete
- E[X] = Σ x · P(X = x)
- Sum over all values x that X can take. The probabilities must add to 1.
- Expectation, continuous
- E[X] = ∫ x · f(x) dx
- Integrate over the range where f(x) > 0. Check that ∫ f(x) dx = 1.
- Expectation of a function
- E[g(X)] = Σ g(x) · P(X = x) or E[g(X)] = ∫ g(x) · f(x) dx
- Use the original probabilities or density of X, not those of g(X).
- Linearity
- E[aX + b] = a·E[X] + b
- Holds for any constants a and b. Also E[X + Y] = E[X] + E[Y] for any X and Y.
- Variance from expectations
- Var(X) = E[X²] − (E[X])²
- Needs E[X²], which is E[g(X)] with g(x) = x².
- Expectation from survival function
- E[X] = ∫ from 0 to ∞ of P(X > x) dx
- For a non-negative continuous variable. Useful when the survival function is simple.
How to solve Expectation of a Random Variable questions
Use this method for any question that asks for a mean or the expectation of a function.
- 1Identify whether X is discrete or continuous, and write its range.
- 2Write down the probability function P(X = x) or the density f(x). If a constant is unknown, find it first using total probability = 1.
- 3Write the function g(x) you need. For the plain mean, g(x) = x.
- 4Set up the sum or integral of g(x) multiplied by the probability or density. Use the correct limits.
- 5Evaluate carefully. For a table, add a column for g(x)·P(X = x).
- 6If the function is piecewise, such as min(X, d) or max(X − d, 0), split the sum or integral at the breakpoint.
- 7Check that the answer is sensible: it must lie within the range of g(X). State the result with units, such as rupees.
Quickest way: Shortcut using linearity and known distributions
When to use it: Use it when X follows a standard distribution or the function is linear in X.
- Recognise the distribution. Binomial(n, p) has mean np, Poisson(λ) has mean λ, Exponential(λ) has mean 1/λ, Uniform(a, b) has mean (a + b)/2.
- For a linear function use E[aX + b] = aE[X] + b. No integration is needed.
- For X², use Var(X) + (E[X])² rather than integrating.
- For non-negative continuous X with a simple survival function, integrate P(X > x) instead.
- Only use the full sum or integral when g is non-linear and not covered above, such as a capped or deductible payment.
Common mistakes in Expectation of a Random Variable
Writing E[g(X)] = g(E[X])
It is true for linear g, so students assume it always holds.
Fix: Apply g to each value inside the sum or integral. For X², compute E[X²] directly or use Var(X) + (E[X])².
Forgetting to multiply by x (or g(x)) and integrating only f(x)
Students confuse the density with the quantity being averaged.
Fix: Write the integrand explicitly as g(x)·f(x) before integrating.
Using wrong limits or ignoring the range of the density
The density is zero outside a range, but students integrate over all values.
Fix: Write the range first. Integrate only where f(x) > 0, and split at breakpoints for piecewise functions.
Not checking that probabilities sum to 1 or that a density integrates to 1
A constant k is left unknown or a table is read wrongly.
Fix: Find k from the total-probability condition before computing any expectation.
Using the distribution of X when computing a payment with a deductible or cap
Students forget the payment is zero (or capped) in part of the range.
Fix: Define the payment as g(x) piecewise, such as max(x − d, 0), and integrate each piece separately.
Worked examples
Example 1
A discrete random variable X takes values 0, 1, 2, 3 with probabilities 0.1, 0.3, 0.4, 0.2. Find E[X] and E[X²], and hence Var(X).
Show the solution
- Check the probabilities: 0.1 + 0.3 + 0.4 + 0.2 = 1.
- E[X] = 0(0.1) + 1(0.3) + 2(0.4) + 3(0.2) = 0 + 0.3 + 0.8 + 0.6 = 1.7.
- E[X²] = 0(0.1) + 1(0.3) + 4(0.4) + 9(0.2) = 0 + 0.3 + 1.6 + 1.8 = 3.7.
- Var(X) = E[X²] − (E[X])² = 3.7 − 1.7² = 3.7 − 2.89 = 0.81.
Answer: E[X] = 1.7, E[X²] = 3.7, Var(X) = 0.81.
Example 2
A claim amount X (in ₹ thousands) has density f(x) = 2x for 0 < x < 1, and 0 otherwise. The insurer pays the claim in excess of ₹ 0.5 thousand only, so the payment is Y = max(X − 0.5, 0). Find E[X] and E[Y].
Show the solution
- Check the density: ∫ from 0 to 1 of 2x dx = [x²] from 0 to 1 = 1. Valid.
- E[X] = ∫ from 0 to 1 of x·2x dx = ∫ 2x² dx = [2x³/3] from 0 to 1 = 2/3.
- Y = 0 when X ≤ 0.5 and Y = X − 0.5 when X > 0.5. So E[Y] = ∫ from 0.5 to 1 of (x − 0.5)·2x dx.
- Expand: (x − 0.5)·2x = 2x² − x.
- Integrate: [2x³/3 − x²/2] from 0.5 to 1.
- At x = 1: 2/3 − 1/2 = 1/6.
- At x = 0.5: 2(0.125)/3 − 0.25/2 = 0.083333 − 0.125 = −0.041667, which is −1/24.
- E[Y] = 1/6 − (−1/24) = 4/24 + 1/24 = 5/24.
Answer: E[X] = 2/3 thousand, about ₹667. E[Y] = 5/24 thousand, about ₹208.33.
Exam tips
- In MCQs, check whether the question wants E[X], E[X²] or Var(X). Examiners often offer E[X²] as a wrong option for the variance.
- For deductible or cap questions, write the payment as a piecewise function before integrating. Marks are given for the setup.
- In written answers, state the formula, the limits and the working. A correct setup earns marks even if the arithmetic slips.
- Check the result lies within the range of the variable. A mean of 1.5 for a variable on (0, 1) means an error.
- If the question gives a survival function, try ∫ P(X > x) dx first. It is often shorter.
Practice questions from Expectations and conditional expectations
- A claim amount X (in rupees thousand) has density f(x) = 2/x^3 for x > 1 and 0 otherwise. What is E[X]?
- The joint probability function of X and Y is P(X=0,Y=0)=0.2, P(X=0,Y=1)=0.1, P(X=1,Y=0)=0.3, P(X=1,Y=1)=0.4. What is E[X | Y = 1]?
- A random variable X has E[X] = 4 and Var(X) = 9. Let Y = 3 − 2X. What is E[Y²]?
- Given Λ, a risk has claim count N with Poisson distribution of mean Λ. Λ takes value 2 with probability 0.5 and value 6 with probability 0.5…
- The number of claims N in a year for a policyholder has mean 3. Each claim amount X has mean Rs 20,000, and claim amounts are independent of…
Expectation of a Random Variable in other exams
The same ground in other exams, if you are preparing for more than one or want another angle on it.
Expectation of a Random Variable: frequently asked questions
What is the difference between E[X] and E[g(X)]?
E[X] is the mean of X itself. E[g(X)] is the mean of a transformed quantity, such as X² or a claim payment. You compute it by putting g(x) inside the sum or integral.
Is E[X²] the same as (E[X])²?
No. E[X²] = Var(X) + (E[X])², so it is larger unless the variance is zero. Students lose marks by treating them as equal.
Does the expectation always exist?
No. The sum or integral must converge absolutely. The Cauchy distribution has no mean. In CS1 questions the mean usually exists, but you should know the condition.
How do I find E[X] for a continuous variable when the density has an unknown constant?
First use ∫ f(x) dx = 1 over the full range to find the constant. Then compute ∫ x·f(x) dx with that value.