---
title: "Expectation and Variance by Integration"
description: "The mean and variance of a continuous variable are integrals against the density, and the same linearity rules from the discrete case still hold."
canonical: https://lightmysky.com/learn/mathematics/expectation-and-variance-by-integration-mt_kRSaKgp3bs
source: https://lightmysky.com/learn/mathematics/expectation-and-variance-by-integration-mt_kRSaKgp3bs.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Expectation and Variance by Integration

The mean and variance of a continuous variable are integrals against the density, and the same linearity rules from the discrete case still hold.

Subject: Mathematics · Area: Probability · Ages 19 to 20
Page: https://lightmysky.com/learn/mathematics/expectation-and-variance-by-integration-mt_kRSaKgp3bs

## Ready when they can

- Compute the mean and variance of a continuous variable by integration
- Use linearity of expectation without assuming independence
- Find the expected value of a function of a random variable

## Lesson: Means and spreads by integration

A continuous mean is an integral against the density: E[X] is the integral of x times f(x) dx. Variance measures squared distance from the centre: Var = E[X squared] minus the squared mean. Try X uniform on [0, 6] with density 1/6: E[X] is the integral of x over 6 from 0 to 6, which is 36 over 12 = 3. The midpoint shortcut agrees, since 3 sits halfway between 0 and 6.

**Example.** Finish the spread for that uniform case. You are given E[X squared] = 12 and the mean 3, so Var = 12 minus 9 = 3. Linearity is the superpower here: E[X + Y] = E[X] + E[Y] with no independence small print, and constants slide out. So E[2X + 1] = 2 times 3 + 1 = 7. A friend who demands independence before adding means is wrong.

Functions of a variable ride the same integral: E[g(X)] is the integral of g(x) times f(x) dx. A rate 2 exponential waits with mean 1 over 2 = 0.5 and variance 1 over 4 = 0.25: faster arrivals mean shorter waits. Discrete sums preview all of this, with weights turning into density and sums turning into integrals.

**Tip.** Run the variance recipe in order: mean first, then E[X squared], then subtract the squared mean. The classic slip is reporting E[X squared] as the variance and skipping the subtraction. Always finish that last step.

**Recap.** Integrate x against the density for the mean, then subtract the squared mean from E[X squared] for the variance.

## Practice

13 questions on this page, each with its working shown.

## Needs first

- [Improper Integrals and Their Convergence](https://lightmysky.com/learn/mathematics/improper-integrals-and-their-convergence-mt_gvtZPFRA6Z)
- [Continuous Random Variables and Density Functions](https://lightmysky.com/learn/mathematics/continuous-random-variables-and-density-functions-mt_jlf4zDTeNm)
- [Expected Value and Variance of a Discrete Random Variable](https://lightmysky.com/learn/mathematics/expected-value-and-variance-of-a-discrete-random-variable-mt_PFdo0Nm3FP)

## Opens up

- [Martingales and Optional Stopping](https://lightmysky.com/learn/mathematics/martingales-and-optional-stopping-mt_198uXX3jRJ)
- [Normalisation and Expectation Values](https://lightmysky.com/learn/science/normalisation-and-expectation-values-mt_6Y3DZ8P1qm)
- [Joint Distributions, Covariance and Independence](https://lightmysky.com/learn/mathematics/joint-distributions-covariance-and-independence-mt_YyTFTAqhSF)
