Continuous Random Variables

A2 · S2 · 10 min

A continuous random variable can take any value in an interval: a time, a length, a mass, a waiting time. Its probabilities are not listed in a table but described by a curve, the probability density function, and probabilities are areas under that curve. On Paper 6 every continuous random variable question begins with a density function like f(x)=kx(4−x)f(x) = kx(4 - x), and asks you to find kk, sketch the graph, find probabilities, and then the mean, variance, median or a percentile. This note covers the density function itself and probabilities; the next two notes cover the averages and spread.

From bars to a curve

For a discrete random variable, each value has its own probability, and those probabilities add to 11. Draw them as bars of width 11 and the area of each bar is its probability.

Now imagine measuring a waiting time more and more precisely: to the nearest minute, then the nearest second, then the nearest hundredth of a second. The bars get narrower and more numerous, each one with a tinier probability, while the total area stays 11. In the limit, the tops of the bars become a smooth curve. That curve is the probability density function.

Two consequences follow immediately.

  • Probability is area. The probability that XX lies between aa and bb is the area under the curve between aa and bb, which is an integral.
  • A single value has probability zero. The "bar" above one exact value has zero width, so zero area: P(X=2)=0P(X = 2) = 0. Only intervals have positive probability. As a result, for a continuous variable, << and ≤\le give the same probability: P(X<2)=P(X≤2)P(X < 2) = P(X \le 2).

The height f(x)f(x) is not itself a probability. It is a density: probability per unit of xx. It can be bigger than 11, as long as the total area is 11.

The probability density function

Definition

A continuous random variable XX has a probability density function (pdf) f(x)f(x) such that

  • f(x)≥0f(x) \ge 0 for all xx;
  • the total area under the graph is 11: ∫−∞∞f(x) dx=1\displaystyle\int_{-\infty}^{\infty} f(x)\,dx = 1, which in practice means integrating over the interval where f(x)f(x) is non-zero;
  • probabilities are areas:
P(a<X<b)=∫abf(x) dx.P(a < X < b) = \int_a^b f(x)\,dx.

On Paper 6 the density is non-zero on a single interval only, and is written in the form

f(x)={332x(4−x)0≤x≤4,0otherwise.f(x) = \begin{cases} \tfrac{3}{32}x(4 - x) & 0 \le x \le 4, \\ 0 & \text{otherwise.} \end{cases}

The interval may be infinite, for example f(x)=3x4f(x) = \dfrac{3}{x^4} for x≥1x \ge 1. Such integrals are improper integrals, worked out by letting the upper limit tend to infinity.

Key result

To be a valid pdf on its interval, ff must satisfy

f(x)≥0and∫intervalf(x) dx=1.f(x) \ge 0 \quad\text{and}\quad \int_{\text{interval}} f(x)\,dx = 1.P(a<X<b)=P(a≤X≤b)=∫abf(x) dx,P(X=a)=0.P(a < X < b) = P(a \le X \le b) = \int_a^b f(x)\,dx, \qquad P(X = a) = 0.

Finding the constant

Most questions give the density with an unknown constant kk. The total-area condition gives an equation for kk.

Finding k
  1. Write the integral of f(x)f(x) over its whole interval and set it equal to 11.
  2. Integrate and substitute the limits. For an infinite upper limit, use the fact that terms like 1xn\dfrac{1}{x^n} (with n>0n > 0) and e−axe^{-ax} (with a>0a > 0) tend to 00.
  3. Solve for kk. If asked to "show that k=…k = \dots", show every step and do not start from the answer.
  4. Sanity check: is f(x)≥0f(x) \ge 0 throughout the interval with your kk?
A polynomial density

The random variable XX has probability density function

f(x)={kx(4−x)0≤x≤4,0otherwise.f(x) = \begin{cases} kx(4 - x) & 0 \le x \le 4, \\ 0 & \text{otherwise.} \end{cases}

(a) Show that k=332k = \dfrac{3}{32}.

(b) Sketch the graph of ff.

(c) Find P(X>3)P(X > 3).

Solution

(a)

∫04k(4x−x2) dx=k[2x2−x33]04=k(32−643)=32k3\int_0^4 k(4x - x^2)\,dx = k\left[2x^2 - \frac{x^3}{3}\right]_0^4 = k\left(32 - \frac{64}{3}\right) = \frac{32k}{3}

Setting this equal to 11 gives k=332k = \dfrac{3}{32}.

(b) The graph is an arch, zero at x=0x = 0 and x=4x = 4, symmetric about x=2x = 2, with maximum f(2)=332×4=0.375f(2) = \frac{3}{32} \times 4 = 0.375. It is zero outside [0,4][0, 4].

y = (3/32) x (4 - x) + 0*sqrt(x (4 - x)) fill 3 4 y = (3/32) x (4 - x)

The shaded region is P(X>3)P(X > 3).

(c)

P(X>3)=332∫34(4x−x2) dx=332[2x2−x33]34=332(323−9)=332×53=532P(X > 3) = \frac{3}{32}\int_3^4 (4x - x^2)\,dx = \frac{3}{32}\left[2x^2 - \frac{x^3}{3}\right]_3^4 = \frac{3}{32}\left(\frac{32}{3} - 9\right) = \frac{3}{32} \times \frac{5}{3} = \frac{5}{32}

So P(X>3)=532=0.15625P(X > 3) = \dfrac{5}{32} = 0.15625.

Sketching a pdf

A Paper 6 sketch needs the right shape, the end points of the interval marked on the xx-axis, the value of ff at any important points (ends, maximum), and f=0f = 0 outside the interval (along the axis). It does not need to be drawn to scale. For polynomials, find where ff is zero and where it is greatest; for a decreasing function like 3x4\frac{3}{x^4}, show it falling towards the axis without touching it.

An infinite interval

The random variable XX has probability density function f(x)=kx4f(x) = \dfrac{k}{x^4} for x≥1x \ge 1, and f(x)=0f(x) = 0 otherwise.

(a) Find kk.

(b) Find P(X>2)P(X > 2).

Solution

(a)

∫1∞kx−4 dx=k[−13x3]1∞=k(0−(−13))=k3=1  ⇒  k=3\int_1^\infty kx^{-4}\,dx = k\left[-\frac{1}{3x^3}\right]_1^\infty = k\left(0 - \left(-\frac{1}{3}\right)\right) = \frac{k}{3} = 1 \;\Rightarrow\; k = 3

As x→∞x \to \infty, 13x3→0\dfrac{1}{3x^3} \to 0, which is why the upper limit contributes 00.

(b)

P(X>2)=∫2∞3x−4 dx=[−1x3]2∞=0+18=18P(X > 2) = \int_2^\infty 3x^{-4}\,dx = \left[-\frac{1}{x^3}\right]_2^\infty = 0 + \frac{1}{8} = \frac{1}{8}
y = 3/x^4 + 0*sqrt(x - 1) fill 2 5 y = 3/x^4

Notice that f(1)=3f(1) = 3: a density can be greater than 11. What matters is that the area is 11.

An exponential density

The time, TT minutes, that a customer waits to be served has probability density function f(t)=ke−t/2f(t) = ke^{-t/2} for t≥0t \ge 0, and 00 otherwise.

(a) Find kk.

(b) Find the probability that a customer waits more than 33 minutes.

Solution

(a)

∫0∞ke−t/2 dt=k[−2e−t/2]0∞=k(0+2)=2k=1  ⇒  k=12\int_0^\infty ke^{-t/2}\,dt = k\left[-2e^{-t/2}\right]_0^\infty = k(0 + 2) = 2k = 1 \;\Rightarrow\; k = \frac{1}{2}

(b)

P(T>3)=∫3∞12e−t/2 dt=[−e−t/2]3∞=e−1.5=0.223P(T > 3) = \int_3^\infty \tfrac{1}{2}e^{-t/2}\,dt = \left[-e^{-t/2}\right]_3^\infty = e^{-1.5} = 0.223

Two unknowns and repeated observations

If a density contains two unknown constants, you need two equations: one from the total area and one from extra information, typically a given probability or (see the next note) a given mean.

Once you have a probability pp for one observation, a question about several independent observations is a binomial question, exactly as with the Poisson.

An exam-style question with two constants

The random variable XX has probability density function f(x)=a+bxf(x) = a + bx for 0≤x≤20 \le x \le 2, and f(x)=0f(x) = 0 otherwise, where aa and bb are constants. It is given that P(X<1)=0.375P(X < 1) = 0.375.

(a) Find aa and bb.

(b) Three independent observations of XX are taken. Find the probability that exactly two of them are greater than 11.

Solution

(a) Total area:

∫02(a+bx) dx=[ax+bx22]02=2a+2b=1  ⇒  a+b=0.5\int_0^2 (a + bx)\,dx = \left[ax + \frac{bx^2}{2}\right]_0^2 = 2a + 2b = 1 \;\Rightarrow\; a + b = 0.5

Given probability:

∫01(a+bx) dx=a+b2=0.375\int_0^1 (a + bx)\,dx = a + \frac{b}{2} = 0.375

Subtracting: b2=0.125\dfrac{b}{2} = 0.125, so b=0.25b = 0.25 and a=0.25a = 0.25.

Check: f(x)=0.25+0.25x>0f(x) = 0.25 + 0.25x > 0 on [0,2][0, 2], so it is a valid pdf.

(b) P(X>1)=1−0.375=0.625P(X > 1) = 1 - 0.375 = 0.625. Let NN be the number of observations greater than 11; N∼B(3,0.625)N \sim B(3, 0.625).

P(N=2)=(32)(0.625)2(0.375)=0.439P(N = 2) = \binom{3}{2}(0.625)^2(0.375) = 0.439
Beyond the syllabus: the cumulative distribution function

The function F(x)=P(X≤x)=∫lower endxf(t) dtF(x) = P(X \le x) = \displaystyle\int_{\text{lower end}}^{x} f(t)\,dt is called the cumulative distribution function. The 9709 syllabus states that explicit knowledge of it is not required, so you will not be asked to find or use FF by name. You will, however, use exactly this kind of integral with a variable upper limit when finding medians and percentiles.

Common mistakes
  • Treating f(x)f(x) as a probability. f(2)=0.375f(2) = 0.375 does not mean P(X=2)=0.375P(X = 2) = 0.375; P(X=2)=0P(X = 2) = 0. Probabilities come from integrating.
  • Integrating over the wrong range. Use only the interval on which ff is defined. Outside it, f=0f = 0 contributes nothing.
  • Mishandling infinite limits. [−13x3]1∞=0−(−13)\left[-\frac{1}{3x^3}\right]_1^\infty = 0 - \left(-\frac{1}{3}\right), not −13-\frac{1}{3}. Keep careful track of signs.
  • "Showing" kk by substituting it in. "Show that k=332k = \frac{3}{32}" must be derived from the total-area equation, with the integral visible.
  • Forgetting the zero part of the sketch. The graph should be drawn as zero (along the axis) outside the interval, and the ends of the interval labelled.
  • Missing the non-negativity check. If a calculated constant makes f(x)f(x) negative anywhere on the interval, something is wrong.
Exam tip
  • Show the integral, the antiderivative in square brackets, and the substituted limits. On "show that" questions the examiner needs every line.
  • Exact answers (532\frac{5}{32}) are fine and often preferred; otherwise give 3 significant figures.
  • A sketch earns marks for the correct shape over the correct interval, with key values labelled. A sketch of the formula outside the interval (for example continuing the parabola below the axis) loses the mark.
  • When the question uses P(X<a)P(X < a) and you have computed P(X≤a)P(X \le a), there is nothing to adjust: for a continuous variable they are equal. Do not apply a continuity correction.
  • Expect a binomial follow-up: "three independent observations... exactly two exceed 1".
Summary
  • A pdf satisfies f(x)≥0f(x) \ge 0 and total area 11.
  • P(a<X<b)=∫abf(x) dxP(a < X < b) = \displaystyle\int_a^b f(x)\,dx; single values have probability 00, so << and ≤\le are interchangeable.
  • Find unknown constants from the total area (and a second condition if there are two).
  • Infinite intervals: let the upper limit tend to infinity; x−n→0x^{-n} \to 0 and e−ax→0e^{-ax} \to 0.
  • f(x)f(x) is a density, not a probability, and can exceed 11.
  • Sketches: correct shape on the correct interval, ends labelled, zero elsewhere.
  • Several independent observations lead to a binomial calculation.

Practice questions

Question
  1. f(x)=k(x+1)f(x) = k(x + 1) for 0≤x≤20 \le x \le 2, and 00 otherwise. Find kk and P(X<1)P(X < 1).
  2. f(x)=kx2f(x) = \dfrac{k}{x^2} for 1≤x≤41 \le x \le 4, and 00 otherwise. Find kk and P(X>2)P(X > 2).
  3. Explain why f(x)=x−1f(x) = x - 1 for 0≤x≤20 \le x \le 2 (and 00 otherwise) is not a probability density function.
  4. f(x)=kx3f(x) = \dfrac{k}{x^3} for x≥2x \ge 2, and 00 otherwise. Find kk and P(X<4)P(X < 4).
  5. f(x)=kcos⁡xf(x) = k\cos x for 0≤x≤π20 \le x \le \frac{\pi}{2}, and 00 otherwise. Find kk and P(X<π6)P\left(X < \frac{\pi}{6}\right).
  6. f(x)=ke−2xf(x) = ke^{-2x} for x≥0x \ge 0, and 00 otherwise. Find kk and P(X>1)P(X > 1).
  7. f(x)=kx2f(x) = kx^2 for 0≤x≤a0 \le x \le a, and 00 otherwise, where kk and aa are positive constants. Given that P(X>1)=78P(X > 1) = \dfrac{7}{8}, find kk and aa.
  8. The lifetime, TT hours, of a type of bulb has probability density function f(t)=kt2f(t) = \dfrac{k}{t^2} for t≥1000t \ge 1000, and 00 otherwise. (a) Find kk. (b) Find the probability that a bulb lasts more than 20002000 hours. (c) Three bulbs are fitted. Assuming their lifetimes are independent, find the probability that at least one of them fails within 15001500 hours.
Answers
  1. ∫02k(x+1) dx=k[x22+x]02=4k=1\displaystyle\int_0^2 k(x + 1)\,dx = k\left[\tfrac{x^2}{2} + x\right]_0^2 = 4k = 1, so k=14k = \tfrac{1}{4}. P(X<1)=14[x22+x]01=14×32=38P(X < 1) = \tfrac{1}{4}\left[\tfrac{x^2}{2} + x\right]_0^1 = \tfrac{1}{4} \times \tfrac{3}{2} = \tfrac{3}{8}.

  2. ∫14kx−2 dx=k[−1x]14=k(1−14)=3k4=1\displaystyle\int_1^4 kx^{-2}\,dx = k\left[-\tfrac{1}{x}\right]_1^4 = k\left(1 - \tfrac{1}{4}\right) = \tfrac{3k}{4} = 1, so k=43k = \tfrac{4}{3}. P(X>2)=43[−1x]24=43(12−14)=13P(X > 2) = \tfrac{4}{3}\left[-\tfrac{1}{x}\right]_2^4 = \tfrac{4}{3}\left(\tfrac{1}{2} - \tfrac{1}{4}\right) = \tfrac{1}{3}.

  3. f(x)<0f(x) < 0 for 0≤x<10 \le x < 1, and a density cannot be negative. (Also the total area is ∫02(x−1) dx=0\int_0^2 (x - 1)\,dx = 0, not 11.)

  4. ∫2∞kx−3 dx=k[−12x2]2∞=k8=1\displaystyle\int_2^\infty kx^{-3}\,dx = k\left[-\tfrac{1}{2x^2}\right]_2^\infty = \tfrac{k}{8} = 1, so k=8k = 8. P(X<4)=8[−12x2]24=8(18−132)=34P(X < 4) = 8\left[-\tfrac{1}{2x^2}\right]_2^4 = 8\left(\tfrac{1}{8} - \tfrac{1}{32}\right) = \tfrac{3}{4}.

  5. ∫0π/2kcos⁡x dx=k[sin⁡x]0π/2=k=1\displaystyle\int_0^{\pi/2} k\cos x\,dx = k[\sin x]_0^{\pi/2} = k = 1. P(X<π6)=sin⁡π6=12P\left(X < \tfrac{\pi}{6}\right) = \sin\tfrac{\pi}{6} = \tfrac{1}{2}.

  6. ∫0∞ke−2x dx=k[−12e−2x]0∞=k2=1\displaystyle\int_0^\infty ke^{-2x}\,dx = k\left[-\tfrac{1}{2}e^{-2x}\right]_0^\infty = \tfrac{k}{2} = 1, so k=2k = 2. P(X>1)=[−e−2x]1∞=e−2=0.135P(X > 1) = \left[-e^{-2x}\right]_1^\infty = e^{-2} = 0.135.

  7. Total area: ka33=1\dfrac{ka^3}{3} = 1. P(X>1)=k(a3−1)3=78P(X > 1) = \dfrac{k(a^3 - 1)}{3} = \dfrac{7}{8}. Subtracting: k3=1−78=18\dfrac{k}{3} = 1 - \dfrac{7}{8} = \dfrac{1}{8}, so k=38k = \dfrac{3}{8}, and then a3=3k=8a^3 = \dfrac{3}{k} = 8, so a=2a = 2.

  8. (a) ∫1000∞kt−2 dt=k[−1t]1000∞=k1000=1\displaystyle\int_{1000}^\infty kt^{-2}\,dt = k\left[-\tfrac{1}{t}\right]_{1000}^\infty = \tfrac{k}{1000} = 1, so k=1000k = 1000. (b) P(T>2000)=1000[−1t]2000∞=10002000=12P(T > 2000) = 1000\left[-\tfrac{1}{t}\right]_{2000}^\infty = \tfrac{1000}{2000} = \tfrac{1}{2}. (c) P(T<1500)=1000[−1t]10001500=1000(11000−11500)=13P(T < 1500) = 1000\left[-\tfrac{1}{t}\right]_{1000}^{1500} = 1000\left(\tfrac{1}{1000} - \tfrac{1}{1500}\right) = \tfrac{1}{3}. P(at least one fails)=1−(23)3=1927=0.704P(\text{at least one fails}) = 1 - \left(\tfrac{2}{3}\right)^3 = \tfrac{19}{27} = 0.704.

How well do you know this?

Builds on

Where this leads

Console

Search notes, courses and tools, or run an action