Mean and median for a continuous random variable
In Year 12 Mathematical Methods (Queensland, QCAA), the mean, median and mode summarise a continuous random variable \(X\) described by a probability density function \(f\). The mean (expected value) is \(\mu=E(X)=\int x\,f(x)\,dx\); the median \(m\) splits the total area in half, \(\int_{a}^{m} f(x)\,dx=\tfrac12\); and the mode is the \(x\) that maximises \(f\).
A continuous random variable \(X\) is described by a probability density function \(f\), where \(f(x)\ge 0\) and the total area is \(\int f(x)\,dx=1\). Probabilities are areas: \(P(a\le X\le b)=\int_a^b f(x)\,dx\).
The mean, or expected value, is the balance point of the distribution: \(\mu=E(X)=\int x\,f(x)\,dx\) over the support. Each value \(x\) is weighted by its density \(f(x)\) — note the extra factor of \(x\), without which the integral is just \(1\).
The median \(m\) is the value with equal area on each side: \(\int_{a}^{m} f(x)\,dx=\tfrac12\) (equivalently \(F(m)=\tfrac12\)). The mode is the value of \(x\) that maximises \(f(x)\) — the highest point of the density, found from \(f'(x)=0\) or at an endpoint.
For a function of \(X\), the expected value is \(E(g(X))=\int g(x)\,f(x)\,dx\); for example \(E(X^{2})=\int x^{2} f(x)\,dx\).
The mean (expected value) weights each \(x\) by its density:
The median \(m\) halves the total area:
The mode maximises the density, and the expected value of a function integrates \(g(x)f(x)\):
How to find the mean, median and mode
- Mean. Form \(x\,f(x)\), integrate over the support and evaluate: \(\mu=\int x f(x)\,dx\). Keep the factor of \(x\).
- Median. Set the lower-tail area to \(\tfrac12\): \(\int_{a}^{m} f(x)\,dx=\tfrac12\), then solve the resulting equation for \(m\) (exactly, or with technology).
- Mode. Maximise \(f\): solve \(f'(x)=0\) for an interior maximum (confirm with \(f''<0\) or a sign test). If \(f\) is increasing or decreasing throughout, the mode is the corresponding endpoint.
- Function of \(X\). For \(E(g(X))\) integrate \(g(x)f(x)\); e.g. \(E(X^{2})=\int x^{2} f(x)\,dx\). Remember \(E(X^{2})\ne (E(X))^{2}\).
Integrate \(x\,f(x)\) over \([0,2]\).
| \(\mu\) | \(=\) | \(\displaystyle\int_{0}^{2} x\cdot\dfrac{x}{2}\,dx\) |
| \(\) | \(=\) | \(\dfrac12\left[\dfrac{x^{3}}{3}\right]_{0}^{2}=\dfrac12\cdot\dfrac83\) |
| \(\mu\) | \(=\) | \(\dfrac43\) |
The mean is \(\mu=\dfrac43\).
Set the lower-tail area to \(\tfrac12\) and solve.
| \(\displaystyle\int_{0}^{m}\dfrac{x}{8}\,dx\) | \(=\) | \(\dfrac12\) |
| \(\dfrac{m^{2}}{16}\) | \(=\) | \(\dfrac12\Rightarrow m^{2}=8\) |
| \(m\) | \(=\) | \(2\sqrt2\approx2.83\) |
The median is \(m=2\sqrt2\).
The mode maximises \(f\); solve \(f'(x)=0\).
| \(f'(x)\) | \(=\) | \(\dfrac{3}{32}(4-2x)\) |
| \(f'(x)=0\) | \(\Rightarrow\) | \(x=2\) |
| \(f''(x)\) | \(=\) | \(-\dfrac{3}{16}<0\) (maximum) |
The mode is \(x=2\).
Integrate \(x^{2} f(x)\); this is not the mean squared.
| \(E(X^{2})\) | \(=\) | \(\displaystyle\int_{0}^{2} x^{2}\cdot\dfrac12\,dx\) |
| \(\) | \(=\) | \(\dfrac12\cdot\dfrac83=\dfrac43\) |
| \((E(X))^{2}\) | \(=\) | \(1^{2}=1\neq\dfrac43\) |
So \(E(X^{2})=\dfrac43\), larger than \((E(X))^{2}=1\).
Common pitfalls
Frequently asked questions
How do you find the mean of a continuous random variable?
Integrate \(x\,f(x)\) over the support: \(\mu=\int x f(x)\,dx\). Multiply \(x\) by the density, integrate, and evaluate. Do not drop the factor of \(x\).
How do you find the median?
Set the lower-tail area to a half: \(\int_{a}^{m} f(x)\,dx=\tfrac12\) (that is \(F(m)=\tfrac12\)), then solve for \(m\).
Is the median the same as the mean?
Only when \(f\) is symmetric, in which case both equal the centre. For a skewed density they differ, so compute each on its own.
How do you find the mode?
Maximise \(f\): solve \(f'(x)=0\) for an interior peak (check \(f''<0\)); if \(f\) is monotone the mode is an endpoint.
What is \(E(X^2)\)?
\(E(X^{2})=\int x^{2} f(x)\,dx\). It is the expected value of the function \(x^{2}\), and is generally larger than \((E(X))^{2}\).
Do you use the factor of \(x\) when finding the mean?
Yes. Integrating \(f\) alone gives \(1\); the mean needs the \(x\) weight: \(\mu=\int x f(x)\,dx\).