Lesson 2 of 8 · 18 min

Probability density functions

Check that a function is a probability density function, find an unknown constant, and calculate probabilities as areas with definite integrals, including for the continuous uniform distribution.

What you will be able to do

  • State the two conditions for p(x)p(x) to be a probability density function.
  • Find an unknown constant kk so that the total area under p(x)p(x) is 1.
  • Calculate P(a<X<b)=∫abp(x) dxP(a < X < b) = \int_a^b p(x)\,dx, by integration or by geometry.
  • Recognise and use the continuous uniform distribution and other simple densities in context.

Last lesson the bars of a density histogram settled into a smooth curve as the data grew. Mathematics replaces that curve with a function, the probability density function (pdf), usually written p(x)p(x). Its job is simple: the area under it over an interval is the probability that XX lands in that interval. Since you can now find areas with definite integrals, you can now calculate those probabilities exactly.

Definition

Probability density function

A function p(x)p(x) is a probability density function of a continuous random variable XX if

  1. p(x)≥0p(x) \ge 0 for every xx (a density is never negative), and
  2. ∫−∞∞p(x) dx=1\displaystyle\int_{-\infty}^{\infty} p(x)\,dx = 1 (the total probability is 1).

Then for any a≤ba \le b,

P(a≤X≤b)=∫abp(x) dx.P(a \le X \le b) = \int_a^b p(x)\,dx.

A pdf is usually given by a rule on an interval, and is 0 everywhere else.

Interactive

Make the area equal 1

The curve is p(x)=kx(4−x)p(x) = kx(4 - x) on 0≤x≤40 \le x \le 4. Slide kk until the total area is exactly 1. Only then is it a probability density, and only then is the shaded area P(X<1)P(X < 1).

The widget shows the key idea for finding an unknown constant: the shape is fixed and kk only stretches it vertically, so there is exactly one value of kk that makes the total area 1. Set the integral over the whole interval equal to 1 and solve.

Worked example

Find kk for p(x)=kx(4−x)p(x) = kx(4 - x) and use it

  • Simple familiar
  • Technology free

A continuous random variable XX has probability density function

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

(a) Find the value of kk.

(b) Find P(X<1)P(X < 1).

4 steps

Try it yourself first, then check the working one step at a time.

Method

  1. Write ∫p(x) dx=1\int p(x)\,dx = 1 over the support.

  2. Antidifferentiate, substitute the limits, solve for kk.

  3. Check p(x)≥0p(x) \ge 0 on the support.

  4. Integrate p(x)p(x) over the required interval for each probability.

Watch out for

  • Integrating kk as if it were a variable: it is a constant factor and comes outside.

  • Leaving out the check that p(x)≥0p(x) \ge 0 in a "show that" question.

The random variable XX has probability density function p(x)=kx2p(x) = kx^2 for 0≤x≤30 \le x \le 3, and p(x)=0p(x) = 0 elsewhere. Find the value of kk.

k =
Reads asYour answer shows here as maths.

Once you have a valid pdf, every probability is a definite integral over the interval you want. If the interval runs past the end of the support, cut it off there: the density is 0 outside.

The time XX hours a delivery driver waits at a depot has pdf p(x)=x8p(x) = \frac{x}{8} for 0≤x≤40 \le x \le 4, and 0 elsewhere. Find P(X>2)P(X > 2).

Reads asYour answer shows here as maths.

Common mistake

Mind the support

If p(x)=x8p(x) = \frac{x}{8} only for 0≤x≤40 \le x \le 4, then P(X>2)P(X > 2) is ∫24\int_2^4, never ∫2∞x8 dx\int_2^{\infty} \frac{x}{8}\,dx (which is not even finite). And the value p(3)=38p(3) = \frac{3}{8} is a density, not a probability: P(X=3)=0P(X = 3) = 0.

The simplest continuous model is the continuous uniform distribution: every value in an interval [a,b][a, b] is "equally likely" in the sense that intervals of equal width inside it have equal probability. Its density is a horizontal line, so its probabilities are areas of rectangles.

Key idea

Continuous uniform distribution on [a, b]

p(x)=1b−afor a≤x≤b,p(x)=0 elsewherep(x) = \frac{1}{b - a} \quad \text{for } a \le x \le b, \qquad p(x) = 0 \text{ elsewhere}

For a≤c≤d≤ba \le c \le d \le b, P(c≤X≤d)=d−cb−aP(c \le X \le d) = \dfrac{d - c}{b - a}: the fraction of the interval covered.

Worked example

Waiting for a bus that comes every 12 minutes

  • Foundation
  • Technology free

A bus stops outside a Toowoomba school every 12 minutes. A student arrives at the stop at a random time, so their waiting time WW minutes is uniformly distributed on [0,12][0, 12].

(a) Write down the probability density function of WW.

(b) Find the probability that the student waits more than 8 minutes.

(c) Find P(3<W<7)P(3 < W < 7).

3 steps

Try it yourself first, then check the working one step at a time.

Method

  1. Uniform on [a,b][a, b]: p(x)=1b−ap(x) = \frac{1}{b - a}.

  2. Probability = (width of the interval inside [a,b][a, b]) ×1b−a\times \frac{1}{b - a}.

Watch out for

  • Using a height of 1 instead of 112\frac{1}{12}: the total area would be 12, not 1.

A 10 m rope is cut at a point chosen uniformly at random along its length. Let XX m be the distance from the left end to the cut. Find the probability that the cut is within 2 m of either end.

Simple types of continuous random variable you will meet
ShapeExample pdfTypical context
Uniform (constant)p(x)=112p(x) = \frac{1}{12}, 0≤x≤120 \le x \le 12Waiting for a regular bus, arriving at random
Linear (triangular)p(x)=x8p(x) = \frac{x}{8}, 0≤x≤40 \le x \le 4Values more likely towards one end
Quadratic (hump)p(x)=332x(4−x)p(x) = \frac{3}{32}x(4 - x), 0≤x≤40 \le x \le 4A measurement that clusters in the middle of a range
Exponential decayp(t)=0.2e−0.2tp(t) = 0.2e^{-0.2t}, t≥0t \ge 0Lifetime of a component, time until the next call
Trigonometricp(x)=12sin⁡xp(x) = \frac{1}{2}\sin x, 0≤x≤π0 \le x \le \piAngles, positions on a swinging arc

Exam tip

Show the area is 1

"Show that p(x)p(x) is a probability density function" needs both conditions: say why p(x)≥0p(x) \ge 0 on the interval, and evaluate ∫p(x) dx=1\int p(x)\,dx = 1 with the antiderivative and limits written out. An answer that only does the integral loses a mark.

Summary

  • A pdf satisfies p(x)≥0p(x) \ge 0 and ∫−∞∞p(x) dx=1\int_{-\infty}^{\infty} p(x)\,dx = 1; it is 0 outside its stated interval.

  • To find an unknown constant, set the total integral equal to 1 and solve.

  • P(a≤X≤b)=∫abp(x) dxP(a \le X \le b) = \int_a^b p(x)\,dx: integrate only over the part of the interval where p(x)p(x) is non-zero.

  • For straight-line densities, areas of rectangles, triangles and trapeziums give the same answers as integration.

  • The continuous uniform distribution on [a,b][a, b] has p(x)=1b−ap(x) = \frac{1}{b - a}, so probabilities are fractions of the interval.

Finished the lesson?

Try the 3 quick checks above and the lesson completes itself, or mark it complete now.

Lesson 2 of 80% read

Save your progress with a free account