Median and Percentiles of Continuous Random Variables
The median of a continuous random variable is the value that splits the area under its density function exactly in half. Quartiles and percentiles work the same way with other fractions of the area. On Paper 6 the median is usually the last part of a continuous random variable question: having found , a probability and the mean, you are asked to find the median, or to show that it satisfies an equation and check where it lies. This note shows how to set up those equations, how to solve them, and how to compare the median with the mean.
The median splits the area in half
For a set of data, the median is the middle value: half the data lie below it and half above. For a continuous random variable there is no list of values, only a density curve. "Half the values lie below it" becomes "half the probability lies below it", and probability is area. So the median is the point on the -axis where a vertical line cuts the area under the curve into two equal parts, each of area .
The median of a continuous random variable with probability density function is the value for which
Equivalently, .
Here "lower end" means the left-hand end of the interval on which is non-zero. Below that point the density is zero and contributes nothing to the area.
The syllabus says that explicit knowledge of the cumulative distribution function is not required, but that you may need to locate the median "by direct consideration of an area". That is exactly the definition above: write down the area from the left-hand end up to , set it equal to , and solve for .
The picture below shows on . The shaded region has area , so its right-hand edge is the median.
Because the density rises to the right, most of the area is near , so the median () is well to the right of the midpoint of the interval.
Quartiles and percentiles
The same idea works for any fraction of the area.
For a continuous random variable with pdf :
- the lower quartile satisfies ;
- the median satisfies ;
- the upper quartile satisfies ;
- the th percentile satisfies .
The interquartile range is .
Questions do not always use these names. "Find the value of such that " is asking for the 90th percentile. "Find the time exceeded by of customers" means , so : the 95th percentile.
Integrating from the other end
Sometimes the upper tail is easier to integrate, especially on an infinite interval. Since too, you may write
and, for the upper quartile, . Both routes give the same answer. Choose the one with the simpler integral and limits.
- Make sure the pdf is complete: if it contains an unknown constant, find it first from the total area.
- Write the area from the lower end of the interval up to the unknown value, say , as an integral with as the upper limit.
- Integrate and substitute the limits, so the left-hand side becomes an expression in .
- Set it equal to the required fraction ( for the median, or for quartiles, for a percentile).
- Solve. If the equation has several roots, keep the one that lies inside the interval where is defined, and say why you rejected the others.
- Give the answer exactly where possible, otherwise to 3 significant figures.
The random variable has probability density function
(a) Find the median of .
(b) Find the interquartile range of .
Solution
(a) Let the median be .
(b) The same integral with the other fractions:
All three values lie in , as they must.
The random variable has probability density function for , and otherwise.
(a) Show that .
(b) Find the median of .
(c) Find the value of such that .
Solution
(a)
(b)
(c) This is the 90th percentile.
Infinite intervals and exponential densities
When the interval is infinite, for example , the area up to is a definite integral with ordinary limits and , so nothing special is needed. Exponential densities lead to equations of the form , which you solve with natural logarithms.
The time, minutes, that a caller waits to be connected has probability density function for , and otherwise. The mean waiting time is minutes.
(a) Find the median waiting time.
(b) Explain, with reference to the shape of the graph of , why the median is less than the mean.
(c) Find the waiting time that is exceeded by only of callers.
Solution
(a)
(b) The density is greatest at and decreases, with a long tail to the right (positive skew). The occasional very long waits pull the mean to the right, but they do not move the median, which depends only on where half of the area is reached. So the median is less than the mean.
The shaded half of the area ends at the median (); the second line is at the mean ().
(c) We need . Integrating the upper tail is quicker:
Symmetry gives the median for free
If the density is symmetrical about a line , then the area to the left of equals the area to the right, so the median is . The mean is also . A symmetrical density therefore has mean = median, and you can quote both without integrating, provided you state the symmetry as the reason.
Symmetry also links the quartiles: if is symmetrical about and the lower quartile is , then the upper quartile is the same distance above , so .
Equations you cannot solve exactly
For a quadratic density such as or , the area up to is a cubic in . Cubic equations usually have no neat solution, so examiners phrase the question as "show that satisfies the equation ..." followed by "verify that lies between ... and ..." or "hence find correct to 2 decimal places".
To verify that a root lies between two values and , substitute both into the expression and show that the values have opposite signs. Because a polynomial is continuous, a change of sign means it passes through zero somewhere between and . This is the same sign-change argument as in Pure Mathematics 2 and 3.
A cubic has up to three real roots. Only one will lie in the interval where is defined, and that is the median; the others are meaningless here.
The random variable has probability density function for , and otherwise.
(a) State the median of , giving a reason.
(b) Show that the lower quartile, , satisfies the equation .
(c) Verify that lies between and .
(d) Hence write down an interval of width that contains the upper quartile.
Solution
(a) The graph of is symmetrical about , so the median is .
(b)
Multiply both sides by :
Multiply by : , so , as required.
(c) Let .
There is a change of sign and is continuous, so the root lies between and . (The other two roots of the cubic are about and , both outside .)
(d) By symmetry about , , so lies between and .
Comparing the median and the mean
Examiners like to ask whether the median is greater or less than the mean, and to make you justify it. Three facts cover nearly every case.
- Symmetrical density: mean median.
- Density with a long tail to the right (for example a decreasing density, or one with its peak near the left end): the mean is pulled towards the tail, so mean median.
- Density with a long tail to the left (for example an increasing density such as ): mean median.
You can always check numerically. A neat test: if , then more than half the area lies below the mean, so the median is below the mean.
The random variable has probability density function for , and otherwise.
(a) Show that .
(b) Find .
(c) Show that the median, , of satisfies , and verify that correct to 2 decimal places.
(d) Find and use your answer to explain whether the median is less than or greater than the mean.
Solution
(a)
(b)
(c)
To verify to 2 decimal places, test the ends of the interval . Let :
The sign changes, so the root lies in and to 2 decimal places.
(d)
This is more than , so the point that cuts off half the area is to the left of the mean: the median is less than the mean. This fits the shape: is greatest at and decreases, so the distribution has its tail to the right.
Unknown constants from a median
A given median or quartile is one more equation, so it can be used to find an unknown constant, in the same way as a given probability or a given mean.
The random variable has probability density function for , and otherwise, where and are constants. The median of is .
Find the values of and .
Solution
Total area:
Median:
From (1), . Substitute into (2):
Then .
Check: on , so is a valid density.
- Setting the integral equal to instead of . The total area is ; the area up to the median is .
- Using the wrong lower limit. The area must start at the left-hand end of the interval where is non-zero, not at (unless the interval starts at ). For on , the lower limit is .
- Confusing the median with the mean. The median comes from ; the mean from . They are equal only for symmetrical densities.
- Taking the median to be the midpoint of the interval. That is only true when is symmetrical.
- Keeping a root outside the interval. A cubic may have a root at for a density on . Reject it, and say why.
- Mixing up upper and lower tails for percentiles. "Exceeded by " means , which is the 95th percentile, not the 5th.
- Verifying a root badly. "Verify that to 2 d.p." needs the sign change across and , not across and , and must state the conclusion.
- Write the defining equation in full before integrating: . This line usually earns the method mark on its own.
- "Show that the median satisfies ..." is a derivation. Show the integral, the substituted limits and each rearrangement until the given equation appears exactly. Do not start from the given equation.
- For "verify" or "show that lies between", substitute both values, state both signs explicitly, and finish with a sentence: "change of sign, so the root lies between and ".
- Exact answers such as , or are acceptable; otherwise give 3 significant figures.
- When asked to compare the median and the mean, a numerical comparison or a reason based on the shape (skewness) is needed. A bare statement "the median is smaller" scores nothing.
- Symmetry is a valid method. Say "by symmetry, the median is " and the mark is yours without any integration.
- The median satisfies .
- Quartiles use and ; the th percentile uses . IQR .
- You may integrate the upper tail instead: .
- Exponential densities lead to logarithms: gives .
- Symmetrical density: median mean centre of symmetry, and .
- Cubic equations: show the equation, then verify the root with a change of sign; keep only the root inside the interval.
- Tail to the right: mean median. Tail to the left: mean median.
- A given median is an extra equation for finding unknown constants.
Practice questions
- has pdf for , and otherwise. Find the median and the lower quartile of .
- has pdf for , and otherwise. Find the median of and the 80th percentile of .
- has pdf for , and otherwise. Find the median and the interquartile range of .
- The lifetime, years, of a component has pdf for , and otherwise. Find the median lifetime, and find the probability that a component lasts more than twice the median lifetime.
- has pdf for , and otherwise. Find , state the median of , and find the upper quartile of .
- has pdf for , and otherwise. Show that the lower quartile, , satisfies , and verify that .
- has pdf for , and otherwise, where is a positive constant. The median of is . Find the exact value of , find to 3 significant figures, and find .
- has pdf for , and otherwise. (a) Verify that is a valid probability density function. (b) Find the exact median of . (c) Find and hence state, with a reason, whether the mean is greater or less than the median. (d) Three independent observations of are taken. Find the probability that all three are less than the median, and the probability that exactly one is less than the mean.
Answers
-
, so and (the negative root is outside ). Lower quartile: , so .
-
, so . 80th percentile: , so .
-
, so and . : , so , . : , so , . IQR .
-
, so years. .
-
, so . The graph is symmetrical about , so the median is . Upper quartile: , so and .
-
, so , , and . With : and . The sign changes, so .
-
, so and . .
-
(a) on , and . (b) , so . (c) . This is greater than , so the mean is greater than the median. (The density decreases, so the tail is to the right.) (d) . . With , .