Skip to content
Family Table Math
Auto

Probability Density Functions

For a continuous random variable, like a waiting time or a length, probability is area under a curve. With calculus you can now work with any curve, not just rectangles and the normal distribution: the curve is a probability density function, and probabilities, the median, the mean and the variance all come from integrals. This page uses calculus, so any trigonometric functions are in radians.

A continuous random variable XX has a probability density function (pdf) f(x)f(x) with two properties:

  • f(x)≥0f(x) \ge 0 for all xx (the curve never goes below the axis);
  • the total area under the curve is 11: ∫−∞∞f(x) dx=1\displaystyle\int_{-\infty}^{\infty} f(x)\,dx = 1.

Most pdfs are zero outside some interval a≤x≤ba \le x \le b, so the condition becomes ∫abf(x) dx=1\displaystyle\int_a^b f(x)\,dx = 1. If a pdf contains an unknown constant kk, this condition is how you find it.

P(c≤X≤d)=∫cdf(x) dxP(c \le X \le d) = \int_c^d f(x)\,dx

This is the area under the curve between cc and dd (see evaluating definite integrals). A single value has no area, so P(X=c)=0P(X = c) = 0, and it doesn’t matter whether you write <\lt or ≤\le.

Note that f(x)f(x) itself is not a probability: it can be bigger than 11. Only areas are probabilities.

  • The mode is the value of xx where f(x)f(x) is greatest. Find it with f′(x)=0f'(x) = 0 (checking it’s a maximum), but remember the maximum can also be at an endpoint of the interval.
  • The median mm splits the area in half:
∫−∞mf(x) dx=12\int_{-\infty}^{m} f(x)\,dx = \frac{1}{2}

Solve this equation for mm, by hand if you can, or with your GDC’s solver.

These are the continuous versions of the formulas for discrete random variables, with sums replaced by integrals:

E(X)=μ=∫−∞∞xf(x) dxE(X2)=∫−∞∞x2f(x) dxE(X) = \mu = \int_{-\infty}^{\infty} x f(x)\,dx \qquad\qquad E(X^2) = \int_{-\infty}^{\infty} x^2 f(x)\,dx Var(X)=E(X2)−[E(X)]2σ=Var(X)\text{Var}(X) = E(X^2) - [E(X)]^2 \qquad\qquad \sigma = \sqrt{\text{Var}(X)}

The linear transformation rules still hold: E(aX+b)=aE(X)+bE(aX + b) = aE(X) + b and Var(aX+b)=a2 Var(X)\text{Var}(aX + b) = a^2\,\text{Var}(X).

A pdf can be defined by different formulas on different intervals. Integrate each piece over its own interval and add the results. For the median, first find which piece it’s in by checking the area of the first piece.

Shape tells you about mode, median and mean

Section titled “Shape tells you about mode, median and mean”

For a symmetric pdf, the mode (if there’s a single peak), median and mean are all in the middle. If the pdf has a long tail to the right (positively skewed), the mean is pulled right: usually mode <\lt median <\lt mean. Example 3 shows this.

On calculator papers you can find integrals, solve for the median and find the maximum with your GDC. Without a calculator, you need to integrate by hand, so practise both. Exact answers are expected when the integrals are straightforward.

XX has pdf f(x)=kx2f(x) = kx^2 for 0≤x≤30 \le x \le 3, and f(x)=0f(x) = 0 otherwise.

  • (a) Find kk.
  • (b) Find P(1≤X≤2)P(1 \le X \le 2).

Solution.

(a) The total area must be 11:

∫03kx2 dx=k[x33]03=9k=1⇒k=19\int_0^3 kx^2\,dx = k\left[\frac{x^3}{3}\right]_0^3 = 9k = 1 \quad\Rightarrow\quad k = \frac{1}{9}

(b)

P(1≤X≤2)=∫12x29 dx=[x327]12=827−127=727P(1 \le X \le 2) = \int_1^2 \frac{x^2}{9}\,dx = \left[\frac{x^3}{27}\right]_1^2 = \frac{8}{27} - \frac{1}{27} = \frac{7}{27}

Example 2: Mode, median, mean and variance by hand

Section titled “Example 2: Mode, median, mean and variance by hand”

XX has pdf f(x)=x8f(x) = \dfrac{x}{8} for 0≤x≤40 \le x \le 4, and 00 otherwise. Find the mode, median, mean and standard deviation of XX.

Solution.

Mode. f(x)=x8f(x) = \dfrac{x}{8} is increasing, so its largest value is at the endpoint: the mode is 44.

Median.

∫0mx8 dx=m216=12⇒m2=8⇒m=22≈2.83\int_0^m \frac{x}{8}\,dx = \frac{m^2}{16} = \frac{1}{2} \quad\Rightarrow\quad m^2 = 8 \quad\Rightarrow\quad m = 2\sqrt{2} \approx 2.83

(Reject m=−22m = -2\sqrt{2}, which is outside 0≤x≤40 \le x \le 4.)

Mean.

E(X)=∫04x⋅x8 dx=[x324]04=6424=83E(X) = \int_0^4 x \cdot \frac{x}{8}\,dx = \left[\frac{x^3}{24}\right]_0^4 = \frac{64}{24} = \frac{8}{3}

Variance.

E(X2)=∫04x38 dx=[x432]04=8E(X^2) = \int_0^4 \frac{x^3}{8}\,dx = \left[\frac{x^4}{32}\right]_0^4 = 8 Var(X)=8−(83)2=72−649=89\text{Var}(X) = 8 - \left(\frac{8}{3}\right)^2 = \frac{72 - 64}{9} = \frac{8}{9}

The standard deviation is 8/9=223≈0.943\sqrt{8/9} = \dfrac{2\sqrt{2}}{3} \approx 0.943 (3 s.f.).

Example 3: Mode by calculus, median by GDC

Section titled “Example 3: Mode by calculus, median by GDC”

XX has pdf f(x)=364x(4−x)2f(x) = \dfrac{3}{64}x(4 - x)^2 for 0≤x≤40 \le x \le 4, and 00 otherwise.

  • (a) Find the mode.
  • (b) Find the median.
  • (c) Show that E(X)=1.6E(X) = 1.6 and find Var(X)\text{Var}(X).

Solution.

(a) Differentiate x(4−x)2x(4 - x)^2 with the product rule:

ddx[x(4−x)2]=(4−x)2−2x(4−x)=(4−x)(4−3x)\frac{d}{dx}\Big[x(4 - x)^2\Big] = (4 - x)^2 - 2x(4 - x) = (4 - x)(4 - 3x)

This is 00 at x=4x = 4 (where f(x)=0f(x) = 0, a minimum) and at x=43x = \dfrac{4}{3}, where ff has its maximum. The mode is 43≈1.33\dfrac{4}{3} \approx 1.33.

(b) Solve ∫0m364x(4−x)2 dx=0.5\displaystyle\int_0^m \frac{3}{64}x(4 - x)^2\,dx = 0.5 with the GDC (enter the integral as a function of mm and use the solver, or graph it and intersect with y=0.5y = 0.5):

m=1.54 (3 s.f.)m = 1.54 \text{ (3 s.f.)}

(c) Expand: x(4−x)2=16x−8x2+x3x(4 - x)^2 = 16x - 8x^2 + x^3.

E(X)=364∫04(16x2−8x3+x4) dx=364[16x33−2x4+x55]04=364(10243−512+10245)=364⋅51215=1.6E(X) = \frac{3}{64}\int_0^4 (16x^2 - 8x^3 + x^4)\,dx = \frac{3}{64}\left[\frac{16x^3}{3} - 2x^4 + \frac{x^5}{5}\right]_0^4 = \frac{3}{64}\left(\frac{1024}{3} - 512 + \frac{1024}{5}\right) = \frac{3}{64}\cdot\frac{512}{15} = 1.6 E(X2)=364∫04(16x3−8x4+x5) dx=364(1024−81925+20483)=364⋅102415=3.2E(X^2) = \frac{3}{64}\int_0^4 (16x^3 - 8x^4 + x^5)\,dx = \frac{3}{64}\left(1024 - \frac{8192}{5} + \frac{2048}{3}\right) = \frac{3}{64}\cdot\frac{1024}{15} = 3.2 Var(X)=3.2−1.62=0.64\text{Var}(X) = 3.2 - 1.6^2 = 0.64

So the standard deviation is 0.80.8.

Graph of f(x) = 3/64 x (4 - x) squared on 0 to 4, skewed to the right, with the mode 1.33, median 1.54 and mean 1.6 marked. 1 2 3 4 0.2 0.4 mode 1.33 mean 1.6 median 1.54 0.5 y = f(x) x
A pdf with a long tail to the right: mode ≈1.33\approx 1.33, median ≈1.54\approx 1.54, mean =1.6= 1.6.

XX has pdf

f(x)={kx,0≤x≤2k(6−x)2,2<x≤60,otherwisef(x) = \begin{cases} kx, & 0 \le x \le 2 \\ \dfrac{k(6 - x)}{2}, & 2 \lt x \le 6 \\ 0, & \text{otherwise} \end{cases}
  • (a) Find kk.
  • (b) Find P(X>4)P(X \gt 4).
  • (c) Find the median.
  • (d) Find E(X)E(X).

Solution.

(a) Add the areas of the two pieces:

∫02kx dx+∫26k(6−x)2 dx=2k+k2[6x−x22]26=2k+k2(18−10)=6k=1\int_0^2 kx\,dx + \int_2^6 \frac{k(6 - x)}{2}\,dx = 2k + \frac{k}{2}\left[6x - \frac{x^2}{2}\right]_2^6 = 2k + \frac{k}{2}(18 - 10) = 6k = 1

So k=16k = \dfrac{1}{6}. (The graph is a triangle with base 66 and height f(2)=2kf(2) = 2k, so the area is 12(6)(2k)=6k\tfrac{1}{2}(6)(2k) = 6k. ✓)

The pdf is f(x)=x6f(x) = \dfrac{x}{6} on 0≤x≤20 \le x \le 2 and f(x)=6−x12f(x) = \dfrac{6 - x}{12} on 2<x≤62 \lt x \le 6.

(b)

P(X>4)=∫466−x12 dx=112[6x−x22]46=112(18−16)=16P(X \gt 4) = \int_4^6 \frac{6 - x}{12}\,dx = \frac{1}{12}\left[6x - \frac{x^2}{2}\right]_4^6 = \frac{1}{12}(18 - 16) = \frac{1}{6}

(c) The first piece has area ∫02x6 dx=13<12\displaystyle\int_0^2 \frac{x}{6}\,dx = \frac{1}{3} \lt \frac{1}{2}, so the median is in the second piece. It’s easiest to use the area to the right of mm, which must also be 12\tfrac{1}{2}:

∫m66−x12 dx=(6−m)224=12⇒(6−m)2=12⇒m=6−23≈2.54\int_m^6 \frac{6 - x}{12}\,dx = \frac{(6 - m)^2}{24} = \frac{1}{2} \quad\Rightarrow\quad (6 - m)^2 = 12 \quad\Rightarrow\quad m = 6 - 2\sqrt{3} \approx 2.54

(Take 6−m=+126 - m = +\sqrt{12}, since m=6+23m = 6 + 2\sqrt{3} is outside the interval.)

(d)

E(X)=∫02x26 dx+∫26x(6−x)12 dx=818+112[3x2−x33]26=49+112⋅803=49+209=83E(X) = \int_0^2 \frac{x^2}{6}\,dx + \int_2^6 \frac{x(6 - x)}{12}\,dx = \frac{8}{18} + \frac{1}{12}\left[3x^2 - \frac{x^3}{3}\right]_2^6 = \frac{4}{9} + \frac{1}{12}\cdot\frac{80}{3} = \frac{4}{9} + \frac{20}{9} = \frac{8}{3}
Triangular pdf rising from (0, 0) to (2, 1/3) and falling to (6, 0). The area left of the median 2.54 is 0.5, and the area to the right of 4 is 1/6. 1 2 3 4 5 6 1/6 1/3 (2, 1/3) m ≈ 2.54 0.5 1/6 x
The piecewise pdf of Example 4. Half the area lies left of m=6−23≈2.54m = 6 - 2\sqrt{3} \approx 2.54, and P(X>4)=16P(X \gt 4) = \tfrac{1}{6}.

Treating f(x) as a probability. f(2)=13f(2) = \tfrac{1}{3} in Example 4 does not mean P(X=2)=13P(X = 2) = \tfrac{1}{3}. For a continuous variable, P(X=2)=0P(X = 2) = 0; probabilities come from areas.

Forgetting the x in the mean. E(X)=∫xf(x) dxE(X) = \int x f(x)\,dx, not ∫f(x) dx\int f(x)\,dx (that’s always 11). For E(X2)E(X^2), multiply by x2x^2.

Assuming the mode is where f′(x) = 0. The maximum might be at an endpoint, as in Example 2, where ff is increasing all the way to x=4x = 4. Always compare with the endpoints.

Integrating over the wrong interval for the median. For a piecewise pdf, check the area of the first piece first. If it’s less than 12\tfrac{1}{2}, the median is in a later piece, and you must include the whole first piece’s area.

Keeping a root outside the domain. Equations for the median often have two solutions. Keep only the one inside the interval where the pdf is defined.

Writing Var(X) = E(X²). Subtract [E(X)]2[E(X)]^2. If your variance is bigger than a quarter of the square of the interval’s width, something has gone wrong.

1. (Warm-up) XX has pdf f(x)=kxf(x) = kx for 0≤x≤20 \le x \le 2, and 00 otherwise. Find kk and P(X<1)P(X \lt 1).

Solution∫02kx dx=k[x22]02=2k=1⇒k=12\int_0^2 kx\,dx = k\left[\frac{x^2}{2}\right]_0^2 = 2k = 1 \quad\Rightarrow\quad k = \frac{1}{2}P(X<1)=∫01x2 dx=[x24]01=14P(X \lt 1) = \int_0^1 \frac{x}{2}\,dx = \left[\frac{x^2}{4}\right]_0^1 = \frac{1}{4}

2. (Warm-up) XX has pdf f(x)=15f(x) = \dfrac{1}{5} for 2≤x≤72 \le x \le 7, and 00 otherwise. Find P(X>6)P(X \gt 6), the median and E(X)E(X).

Solution

P(X>6)=15(7−6)=15P(X \gt 6) = \dfrac{1}{5}(7 - 6) = \dfrac{1}{5} (a rectangle of width 11 and height 15\tfrac{1}{5}).

The pdf is symmetric about the centre of the interval, so the median is 2+72=4.5\dfrac{2 + 7}{2} = 4.5.

E(X)=∫27x5 dx=[x210]27=49−410=4.5E(X) = \int_2^7 \frac{x}{5}\,dx = \left[\frac{x^2}{10}\right]_2^7 = \frac{49 - 4}{10} = 4.5

3. (Core) XX has pdf f(x)=k(4−x2)f(x) = k(4 - x^2) for 0≤x≤20 \le x \le 2, and 00 otherwise.

  • (a) Find kk.
  • (b) Find P(X<1)P(X \lt 1).
  • (c) State the mode and find E(X)E(X).
Solution

(a)

∫02k(4−x2) dx=k[4x−x33]02=k(8−83)=16k3=1⇒k=316\int_0^2 k(4 - x^2)\,dx = k\left[4x - \frac{x^3}{3}\right]_0^2 = k\left(8 - \frac{8}{3}\right) = \frac{16k}{3} = 1 \quad\Rightarrow\quad k = \frac{3}{16}

(b)

P(X<1)=316[4x−x33]01=316⋅113=1116P(X \lt 1) = \frac{3}{16}\left[4x - \frac{x^3}{3}\right]_0^1 = \frac{3}{16}\cdot\frac{11}{3} = \frac{11}{16}

(c) ff is decreasing on 0≤x≤20 \le x \le 2, so the mode is 00.

E(X)=316∫02(4x−x3) dx=316[2x2−x44]02=316(8−4)=34E(X) = \frac{3}{16}\int_0^2 (4x - x^3)\,dx = \frac{3}{16}\left[2x^2 - \frac{x^4}{4}\right]_0^2 = \frac{3}{16}(8 - 4) = \frac{3}{4}

4. (Core) XX has pdf f(x)=38x2f(x) = \dfrac{3}{8}x^2 for 0≤x≤20 \le x \le 2, and 00 otherwise. Find the median, the mean and the variance of XX.

Solution

Median:

∫0m38x2 dx=m38=12⇒m3=4⇒m=43≈1.59\int_0^m \frac{3}{8}x^2\,dx = \frac{m^3}{8} = \frac{1}{2} \quad\Rightarrow\quad m^3 = 4 \quad\Rightarrow\quad m = \sqrt[3]{4} \approx 1.59

Mean and variance:

E(X)=38∫02x3 dx=38⋅4=1.5E(X2)=38∫02x4 dx=38⋅325=2.4E(X) = \frac{3}{8}\int_0^2 x^3\,dx = \frac{3}{8}\cdot 4 = 1.5 \qquad E(X^2) = \frac{3}{8}\int_0^2 x^4\,dx = \frac{3}{8}\cdot\frac{32}{5} = 2.4Var(X)=2.4−1.52=0.15\text{Var}(X) = 2.4 - 1.5^2 = 0.15

5. (Core) XX has pdf f(x)=ksin⁡xf(x) = k\sin x for 0≤x≤π0 \le x \le \pi (radians), and 00 otherwise.

  • (a) Find kk.
  • (b) Find P(X<π3)P\left(X \lt \dfrac{\pi}{3}\right).
  • (c) Write down the mode and the median.
Solution

(a)

∫0πksin⁡x dx=k[−cos⁡x]0π=k(1+1)=2k=1⇒k=12\int_0^{\pi} k\sin x\,dx = k\Big[-\cos x\Big]_0^{\pi} = k(1 + 1) = 2k = 1 \quad\Rightarrow\quad k = \frac{1}{2}

(b)

P(X<π3)=12[−cos⁡x]0π/3=12(−12+1)=14P\left(X \lt \frac{\pi}{3}\right) = \frac{1}{2}\Big[-\cos x\Big]_0^{\pi/3} = \frac{1}{2}\left(-\frac{1}{2} + 1\right) = \frac{1}{4}

(c) sin⁡x\sin x has its maximum at x=π2x = \dfrac{\pi}{2}, so the mode is π2\dfrac{\pi}{2}. The graph is symmetric about x=π2x = \dfrac{\pi}{2}, so the median is also π2\dfrac{\pi}{2}.

6. (Core) XX has pdf

f(x)={x10,0≤x≤2k,2<x≤60,otherwisef(x) = \begin{cases} \dfrac{x}{10}, & 0 \le x \le 2 \\ k, & 2 \lt x \le 6 \\ 0, & \text{otherwise} \end{cases}

Find kk, the median and E(X)E(X).

Solution

Area of the first piece: ∫02x10 dx=420=0.2\displaystyle\int_0^2 \frac{x}{10}\,dx = \frac{4}{20} = 0.2. Area of the second piece: 4k4k. So 0.2+4k=10.2 + 4k = 1 and k=0.2k = 0.2.

The first piece has area 0.2<0.50.2 \lt 0.5, so the median is in the second piece:

0.2+0.2(m−2)=0.5⇒m−2=1.5⇒m=3.50.2 + 0.2(m - 2) = 0.5 \quad\Rightarrow\quad m - 2 = 1.5 \quad\Rightarrow\quad m = 3.5E(X)=∫02x210 dx+∫260.2x dx=830+0.1[x2]26=415+3.2=5215≈3.47E(X) = \int_0^2 \frac{x^2}{10}\,dx + \int_2^6 0.2x\,dx = \frac{8}{30} + 0.1\Big[x^2\Big]_2^6 = \frac{4}{15} + 3.2 = \frac{52}{15} \approx 3.47

7. (Core) XX has pdf f(x)=k e−x/2f(x) = k\,e^{-x/2} for 0≤x≤40 \le x \le 4, and 00 otherwise.

  • (a) Show that k=12(1−e−2)k = \dfrac{1}{2(1 - e^{-2})}.
  • (b) Use your GDC to find the median and the mean of XX.
Solution

(a)

∫04k e−x/2 dx=k[−2e−x/2]04=k(2−2e−2)=1⇒k=12(1−e−2)\int_0^4 k\,e^{-x/2}\,dx = k\Big[-2e^{-x/2}\Big]_0^4 = k(2 - 2e^{-2}) = 1 \quad\Rightarrow\quad k = \frac{1}{2(1 - e^{-2})}

(k≈0.578k \approx 0.578.)

(b) Solving ∫0mk e−x/2 dx=0.5\displaystyle\int_0^m k\,e^{-x/2}\,dx = 0.5 with the GDC gives m=1.13m = 1.13 (3 s.f.). (By hand: e−m/2=1+e−22e^{-m/2} = \dfrac{1 + e^{-2}}{2}, so m=−2ln⁡(1+e−22)m = -2\ln\left(\dfrac{1 + e^{-2}}{2}\right).)

E(X)=∫04x⋅k e−x/2 dx=1.37 (3 s.f., GDC)E(X) = \int_0^4 x \cdot k\,e^{-x/2}\,dx = 1.37 \text{ (3 s.f., GDC)}

8. (Challenge) XX has pdf f(x)=ax+bf(x) = ax + b for 0≤x≤30 \le x \le 3, and 00 otherwise. Given that E(X)=1.75E(X) = 1.75, find aa and bb.

Solution

Total area:

∫03(ax+b) dx=9a2+3b=1\int_0^3 (ax + b)\,dx = \frac{9a}{2} + 3b = 1

Mean:

∫03(ax2+bx) dx=9a+9b2=1.75\int_0^3 (ax^2 + bx)\,dx = 9a + \frac{9b}{2} = 1.75

From the first equation, b=1−4.5a3b = \dfrac{1 - 4.5a}{3}. Substitute into the second:

9a+1.5(1−4.5a)=1.75⇒2.25a=0.25⇒a=199a + 1.5(1 - 4.5a) = 1.75 \quad\Rightarrow\quad 2.25a = 0.25 \quad\Rightarrow\quad a = \frac{1}{9}

Then b=1−0.53=16b = \dfrac{1 - 0.5}{3} = \dfrac{1}{6}.

Check: f(x)=x9+16≥0f(x) = \dfrac{x}{9} + \dfrac{1}{6} \ge 0 on 0≤x≤30 \le x \le 3, so it’s a valid pdf. ✓

9. (Challenge) XX has the pdf from Example 2, f(x)=x8f(x) = \dfrac{x}{8} for 0≤x≤40 \le x \le 4. Let Y=2X+3Y = 2X + 3.

  • (a) Find E(Y)E(Y) and Var(Y)\text{Var}(Y).
  • (b) Find P(Y>9)P(Y \gt 9).
Solution

(a) From Example 2, E(X)=83E(X) = \dfrac{8}{3} and Var(X)=89\text{Var}(X) = \dfrac{8}{9}.

E(Y)=2⋅83+3=253Var(Y)=22⋅89=329E(Y) = 2\cdot\frac{8}{3} + 3 = \frac{25}{3} \qquad \text{Var}(Y) = 2^2\cdot\frac{8}{9} = \frac{32}{9}

(b) Y>9Y \gt 9 means 2X+3>92X + 3 \gt 9, so X>3X \gt 3:

P(X>3)=∫34x8 dx=[x216]34=1−916=716P(X \gt 3) = \int_3^4 \frac{x}{8}\,dx = \left[\frac{x^2}{16}\right]_3^4 = 1 - \frac{9}{16} = \frac{7}{16}