Educerie

Educerie · IB Diploma · Mathematics: analysis and approaches

IB Mathematics AA 4.14 · SL and HL

Discrete and continuous random variables

When a random variable takes a handful of values, or any value in an interval, how do you describe its centre and spread, and what happens to them when you change units?

What you will learn

  • HL Know how to find the mean, variance and standard deviation of a discrete random variable, and that a fair game has expected gain 0
  • HL Understand that a probability density function is never negative, has total area 1 and gives probabilities as areas, including piecewise ones
  • HL Know that the mode is where the density is greatest and the median splits the area in half
  • HL Understand how E(aX + b) and Var(aX + b) follow from E(X) and Var(X)

You must be able to

  1. HL Calculate E(X), E(X squared) and Var(X) for a discrete table or a continuous density
  2. HL Find an unknown constant in a density or a probability table
  3. HL Find the mode and the median of a continuous random variable, including a piecewise one
  4. HL Calculate probabilities from a density by integration
  5. HL Use E(aX + b) = aE(X) + b and Var(aX + b) = a squared Var(X)
  6. Find the fee that makes a game fair

In the exam. HL Paper 1 and Paper 2, often as a whole Section B question of 13 to 19 marks: find kk (3 to 5 marks), a probability (2 to 3), the mode, median or mean (1 to 5 each), the variance (3 to 5), then E(aX+b)\mathrm{E}(aX + b) and Var(aX+b)\mathrm{Var}(aX + b) (2 to 3). Paper 1 densities are integrated by hand and are not always polynomials (sin⁡\sin, arcsin⁡\arcsin and square roots appear), so substitution and integration by parts from Topic 5 matter. Paper 2 hands harder integrals and the median equation to the GDC, and sometimes puts a parameter in the density and asks for E(X)\mathrm{E}(X) or Var(X)\mathrm{Var}(X) in terms of it. The unit also appears on HL Paper 3 (6 of the 43 examined parts on record). Paper 3 asks the same syllabus at length, so expect the constant, mean and variance of a density, possibly with a parameter, strung into one extended problem.

1Discrete random variables: mean and variance

Example: goals per match, XX, for a football team.

xx01234
P(X=x)\mathrm{P}(X = x)0.20.350.250.150.05

The expected value or mean is the probability-weighted average, E(X)=∑x P(X=x)\mathrm{E}(X) = \sum x\,\mathrm{P}(X = x).

E(X)=0(0.2)+1(0.35)+2(0.25)+3(0.15)+4(0.05)=0+0.35+0.5+0.45+0.2=1.5\begin{aligned}\mathrm{E}(X) &= 0(0.2) + 1(0.35) + 2(0.25) + 3(0.15) + 4(0.05) \\[6pt] &= 0 + 0.35 + 0.5 + 0.45 + 0.2 = 1.5\end{aligned}

No match ends with 1.51.5 goals. The mean is the long-run average, the balance point in Figure 1.

Variance measures spread: the expected squared distance from the mean, Var(X)=E[(X−μ)2]\mathrm{Var}(X) = \mathrm{E}\left[(X - \mu)^{2}\right] with μ=E(X)\mu = \mathrm{E}(X).

The booklet gives two versions:

Var(X)=∑(x−μ)2 P(X=x)=∑x2 P(X=x)−μ2\mathrm{Var}(X) = \sum (x - \mu)^{2}\,\mathrm{P}(X = x) = \sum x^{2}\,\mathrm{P}(X = x) - \mu^{2}, that is, Var(X)=E(X2)−[E(X)]2\mathrm{Var}(X) = \mathrm{E}(X^{2}) - [\mathrm{E}(X)]^{2}.

The second is nearly always faster. E(X2)\mathrm{E}(X^{2}) = the expected value of the square: square each value, weight by its probability, add. More generally, E(g(X))=∑g(x) P(X=x)\mathrm{E}\big(g(X)\big) = \sum g(x)\,\mathrm{P}(X = x) for any rule gg.

E(X2)=02(0.2)+12(0.35)+22(0.25)+32(0.15)+42(0.05)=0+0.35+1+1.35+0.8=3.5\begin{aligned}\mathrm{E}(X^{2}) &= 0^{2}(0.2) + 1^{2}(0.35) + 2^{2}(0.25) + 3^{2}(0.15) + 4^{2}(0.05) \\[6pt] &= 0 + 0.35 + 1 + 1.35 + 0.8 = 3.5\end{aligned}Var(X)=3.5−1.52=1.25\mathrm{Var}(X) = 3.5 - 1.5^{2} = 1.25σ=1.25=1.12 (3 s.f.)\sigma = \sqrt{1.25} = 1.12 \text{ (3 s.f.)}
  • The mode of a discrete variable is the value with the greatest probability. In Figure 1 it is 1.
  • E(X2)=3.5\mathrm{E}(X^{2}) = 3.5 is not [E(X)]2=2.25[\mathrm{E}(X)]^{2} = 2.25. The gap is the variance.
  • Variance is in goals2^{2}, so interpret the standard deviation, in goals. Figure 1 marks both.
Figure 1 · A discrete distribution, its mean and its spread 0 1 2 3 4 0 0.1 0.2 0.3 0.4 number of goals, x P(X = x) 0.2 0.35 0.25 0.15 0.05 E(X) = 1.5 σ ≈ 1.12 Goals per match. E(X) = 1.5 is the balance point; σ = 1.12 measures the typical distance from it.
Figure 1 · A discrete distribution, its mean and its spread

Example (Paper 1): the variable XX has P(X=x)=kx+1\mathrm{P}(X = x) = \dfrac{k}{x + 1} for x∈{0,1,2}x \in \{0, 1, 2\}. Find kk, E(X)\mathrm{E}(X) and Var(X)\mathrm{Var}(X).

k(1+12+13)=11k6=1, so k=611probabilities sum to 1k\left(1 + \frac{1}{2} + \frac{1}{3}\right) = \frac{11k}{6} = 1, \text{ so } k = \frac{6}{11} \qquad \textcolor{#838c91}{\text{probabilities sum to 1}}E(X)=611(0+12+23)=611⋅76=711\mathrm{E}(X) = \frac{6}{11}\left(0 + \frac{1}{2} + \frac{2}{3}\right) = \frac{6}{11}\cdot\frac{7}{6} = \frac{7}{11}E(X2)=611(0+12+43)=611⋅116=1\mathrm{E}(X^{2}) = \frac{6}{11}\left(0 + \frac{1}{2} + \frac{4}{3}\right) = \frac{6}{11}\cdot\frac{11}{6} = 1Var(X)=1−(711)2=121−49121=72121\mathrm{Var}(X) = 1 - \left(\frac{7}{11}\right)^{2} = \frac{121 - 49}{121} = \frac{72}{121}

Leave Paper 1 answers exact unless the question asks for decimals.

Example: a table can hide two probabilities. The total of 1 is one equation; a given mean is the second. Let P(X=x)\mathrm{P}(X = x) be 0.1, a, b, 0.40.1,\ a,\ b,\ 0.4 for x=1,2,3,4x = 1, 2, 3, 4, with E(X)=2.9\mathrm{E}(X) = 2.9.

0.1+a+b+0.4=1, so a+b=0.50.1 + a + b + 0.4 = 1, \text{ so } a + b = 0.50.1+2a+3b+1.6=2.9, so 2a+3b=1.20.1 + 2a + 3b + 1.6 = 2.9, \text{ so } 2a + 3b = 1.2b=1.2−2(0.5)=0.2 and a=0.3b = 1.2 - 2(0.5) = 0.2 \text{ and } a = 0.3

Example: let P(X=0), P(X=1), P(X=2)\mathrm{P}(X = 0),\ \mathrm{P}(X = 1),\ \mathrm{P}(X = 2) be 0.61, a, a20.61,\ a,\ a^{2}.

The total gives a2+a−0.39=0a^{2} + a - 0.39 = 0, so a=0.3a = 0.3 or a=−1.3a = -1.3. A probability cannot be negative. Keep a=0.3a = 0.3 and say why you rejected the other root.

2Fair games and expected gain

  • Let XX be a player's gain: the amount received minus the fee paid. The game is fair when E(X)=0\mathrm{E}(X) = 0.
  • Fair does not mean winning half the time. Nobody profits in the long run, because the fee equals the expected prize.

Example: a fairground stand sells a draw from a bag of eight tokens. One red pays $12\$12, two blue pay $3\$3, and five white pay nothing. Let WW be the prize.

E(W)=12(18)+3(28)+0(58)=1.5+0.75=2.25\mathrm{E}(W) = 12\left(\tfrac{1}{8}\right) + 3\left(\tfrac{2}{8}\right) + 0\left(\tfrac{5}{8}\right) = 1.5 + 0.75 = 2.25

A fee of cc gives an expected gain of 2.25−c2.25 - c.

  • The game is fair at c=$2.25c = \$2.25.
  • At $3\$3 the expected gain is −$0.75-\$0.75 per draw, the stand's profit.

Insurers and lotteries price the same way, with the customer's expected gain negative.

Spread of the prize: E(W2)=144(18)+9(28)=20.25\mathrm{E}(W^{2}) = 144\left(\tfrac{1}{8}\right) + 9\left(\tfrac{2}{8}\right) = 20.25, so Var(W)=20.25−2.252=15.1875\mathrm{Var}(W) = 20.25 - 2.25^{2} = 15.1875. Section 7 shows the fee leaves it unchanged.

3Continuous random variables and the probability density function

A continuous variable has too many values to list. A probability density function (pdf) f(x)f(x) describes it, and area gives probability:

P(a≤X≤b)=∫abf(x) dx\mathrm{P}(a \le X \le b) = \int_{a}^{b} f(x)\,dx, with f(x)≥0f(x) \ge 0 for all xx and ∫f(x) dx=1\int f(x)\,dx = 1 over all xx (from −∞-\infty to ∞\infty).

  • A single point has zero area. So P(X<1)=P(X≤1)\mathrm{P}(X < 1) = \mathrm{P}(X \le 1) for a continuous variable, but not for a discrete one.
  • f(x)f(x) is a density, not a probability, so it can exceed 1. A variable spread evenly over [0,0.5][0, 0.5] has f(x)=2f(x) = 2 there.
  • Normally ff is a formula on an interval and 0 elsewhere. Then "from −∞-\infty to ∞\infty" shrinks to that interval.

Example (Paper 1): finding kk. A continuous random variable XX has pdf f(x)=kx2(3−x)f(x) = kx^{2}(3 - x) for 0≤x≤30 \le x \le 3, and f(x)=0f(x) = 0 otherwise. Find kk, then P(X<1)\mathrm{P}(X < 1).

∫03k(3x2−x3)dx=1\int_{0}^{3} k\left(3x^{2} - x^{3}\right)dx = 1k[x3−x44]03=1k\left[x^{3} - \frac{x^{4}}{4}\right]_{0}^{3} = 1k(27−814)=1k\left(27 - \frac{81}{4}\right) = 1k(274)=1, so k=427k\left(\frac{27}{4}\right) = 1, \text{ so } k = \frac{4}{27}P(X<1)=427[x3−x44]01=427(1−14)=427⋅34=19\begin{aligned}\mathrm{P}(X < 1) &= \frac{4}{27}\left[x^{3} - \frac{x^{4}}{4}\right]_{0}^{1} \\[6pt] &= \frac{4}{27}\left(1 - \frac{1}{4}\right) = \frac{4}{27}\cdot\frac{3}{4} = \frac{1}{9}\end{aligned}

Figure 2 shows the total area of 1 and the shaded 19\tfrac{1}{9}.

On [0,3][0, 3], x2≥0x^{2} \ge 0 and 3−x≥03 - x \ge 0, so f(x)≥0f(x) \ge 0 too. "Show that ff is a valid pdf" wants both checks.

Figure 2 · For a continuous variable, probability is area 0 0.5 1 1.5 2 2.5 3 0 0.2 0.4 0.6 x f(x) 1/9 total area = 1 f(x) = 0 outside [0, 3] f(x) = (4/27)x²(3 − x) for 0 ≤ x ≤ 3. Total area 1; the shaded area is P(X < 1) = 1/9.
Figure 2 · For a continuous variable, probability is area

For a probability between two limits, P(1<X<2)=427[(8−4)−(1−14)]=427⋅134=1327\mathrm{P}(1 < X < 2) = \dfrac{4}{27}\left[(8 - 4) - \left(1 - \dfrac{1}{4}\right)\right] = \dfrac{4}{27}\cdot\dfrac{13}{4} = \dfrac{13}{27}.

On Paper 2 the GDC gives 0.4810.481 directly.

Example: let f(x)=ksin⁡xf(x) = k\sin x for 0≤x≤π30 \le x \le \dfrac{\pi}{3} and 0 otherwise. Angles are in radians.

k∫0π/3sin⁡x dx=k[−cos⁡x]0π/3=k(1−12)=k2=1, so k=2k\int_{0}^{\pi/3} \sin x\,dx = k\left[-\cos x\right]_{0}^{\pi/3} = k\left(1 - \tfrac{1}{2}\right) = \tfrac{k}{2} = 1, \text{ so } k = 2P(X<π6)=2[−cos⁡x]0π/6=2(1−32)=2−3\mathrm{P}\left(X < \tfrac{\pi}{6}\right) = 2\left[-\cos x\right]_{0}^{\pi/6} = 2\left(1 - \tfrac{\sqrt{3}}{2}\right) = 2 - \sqrt{3}

Example: let f(x)=ax+bf(x) = ax + b for 1≤x≤31 \le x \le 3 and 0 otherwise, with P(X>2)=0.6\mathrm{P}(X > 2) = 0.6.

Two unknowns need two equations: total area 1, and given area 0.6.

∫13(ax+b) dx=4a+2b=1\int_{1}^{3} (ax + b)\,dx = 4a + 2b = 1∫23(ax+b) dx=52a+b=0.6\int_{2}^{3} (ax + b)\,dx = \frac{5}{2}a + b = 0.6b=0.5−2a, so 2.5a+0.5−2a=0.6, giving a=0.2 and b=0.1b = 0.5 - 2a, \text{ so } 2.5a + 0.5 - 2a = 0.6, \text{ giving } a = 0.2 \text{ and } b = 0.1

Check that f(x)=0.2x+0.1f(x) = 0.2x + 0.1 is non-negative on [1,3][1, 3]. A negative value anywhere on the interval rules the constants out.

Areas also give conditional probabilities: P(X>2.5∣X>2)=P(X>2.5)P(X>2)=0.3250.6=1324\mathrm{P}(X > 2.5 \mid X > 2) = \dfrac{\mathrm{P}(X > 2.5)}{\mathrm{P}(X > 2)} = \dfrac{0.325}{0.6} = \dfrac{13}{24}.

A probability from a pdf can feed the binomial of 4.8. Observe six independent values and let YY count those above 2. Then Y∼B(6, 0.6)Y \sim \mathrm{B}(6,\ 0.6) and E(Y)=3.6\mathrm{E}(Y) = 3.6.

Example: papers sometimes put a letter in the rule or the interval and expect answers in terms of it.

Let f(x)=k(a2−x2)f(x) = k\left(a^{2} - x^{2}\right) for 0≤x≤a0 \le x \le a, where a>0a > 0. The area is k(a3−a33)=2ka33=1k\left(a^{3} - \tfrac{a^{3}}{3}\right) = \tfrac{2ka^{3}}{3} = 1, so k=32a3k = \dfrac{3}{2a^{3}}. Section 5 uses it.

4Mode and median of a continuous random variable

The guide defines both.

  • The mode is a value of xx at which f(x)f(x) is at its maximum. Solve f′(x)=0f'(x) = 0 and show it is a maximum. If ff rises or falls across the whole interval, take the endpoint and say so. Equal peaks in two places give two modes.
  • The median mm splits the area in half: ∫−∞mf(x) dx=12\int_{-\infty}^{m} f(x)\,dx = \tfrac{1}{2}. The lower and upper quartiles use 14\tfrac{1}{4} and 34\tfrac{3}{4} instead. The interquartile range is Q3−Q1Q_{3} - Q_{1}.

The accumulated area F(x)=∫startxf(t) dtF(x) = \int_{\text{start}}^{x} f(t)\,dt climbs from 0 to 1. The median is where it reaches 12\tfrac{1}{2}.

Example: mode. For f(x)=427(3x2−x3)f(x) = \dfrac{4}{27}\left(3x^{2} - x^{3}\right):

f′(x)=427(6x−3x2)=427(3x)(2−x)f'(x) = \frac{4}{27}\left(6x - 3x^{2}\right) = \frac{4}{27}(3x)(2 - x)f′(x)=0 when x=0 or x=2f'(x) = 0 \text{ when } x = 0 \text{ or } x = 2f(0)=0 and f(2)=427(4)(1)=1627, so the mode is 2f(0) = 0 \text{ and } f(2) = \frac{4}{27}(4)(1) = \frac{16}{27}, \text{ so the mode is } 2

Justify the maximum. Either f′f' changes from positive to negative at 2, or f(2)f(2) is bigger than ff at the endpoints.

Example: median. Here you need 427[m3−m44]=12\dfrac{4}{27}\left[m^{3} - \dfrac{m^{4}}{4}\right] = \dfrac{1}{2}, a quartic. It is a Paper 2 job.

427(m3−m44)=12, with 0≤m≤3\frac{4}{27}\left(m^{3} - \frac{m^{4}}{4}\right) = \frac{1}{2}, \text{ with } 0 \le m \le 3m=1.84 (3 s.f.)GDC solver, or intersect y=∫0xf(t) dt with y=0.5m = 1.84 \text{ (3 s.f.)} \qquad \textcolor{#838c91}{\text{GDC solver, or intersect }y = \int_{0}^{x} f(t)\,dt\text{ with }y = 0.5}

Reject any GDC solution outside [0,3][0, 3]. Figure 3 marks mode, median and mean (found in the next section) on the same curve.

Figure 3 · Mode, median and mean of the same density 0 0.5 1 1.5 2 2.5 3 0 0.2 0.4 0.6 x f(x) mode 2 median 1.84 mean 1.8 area 1/2 zoomed in: 1.78 to 2.02 mean 1.8 median 1.84 mode 2 Mode 2 (highest point), median 1.84 (splits the area in half), mean 1.8 (balance point). The long tail on the left pulls the mean below the median, and the median below the mode.
Figure 3 · Mode, median and mean of the same density

Example (Paper 1): the median comes out exactly. For f(x)=2sin⁡xf(x) = 2\sin x on [0,π/3][0, \pi/3], the accumulated area is 2(1−cos⁡m)2(1 - \cos m), so

2(1−cos⁡m)=12, so cos⁡m=34,m=arccos⁡34=0.723 (3 s.f.)2(1 - \cos m) = \frac{1}{2}, \text{ so } \cos m = \frac{3}{4}, \quad m = \arccos\tfrac{3}{4} = 0.723 \text{ (3 s.f.)}

This density has f′(x)=2cos⁡x>0f'(x) = 2\cos x > 0 on the interval, so it is increasing. The mode is the right-hand end, x=π/3x = \pi/3. A mode need not be a stationary point.

5Mean, variance and standard deviation of a continuous random variable

Replace the sum by an integral and P(X=x)\mathrm{P}(X = x) by f(x) dxf(x)\,dx:

E(X)=μ=∫xf(x) dx\mathrm{E}(X) = \mu = \int x f(x)\,dx and Var(X)=∫(x−μ)2f(x) dx=∫x2f(x) dx−μ2\mathrm{Var}(X) = \int (x - \mu)^{2} f(x)\,dx = \int x^{2} f(x)\,dx - \mu^{2}, over all xx. From the formula booklet.

So E(X2)=∫x2f(x) dx\mathrm{E}(X^{2}) = \int x^{2} f(x)\,dx and again Var(X)=E(X2)−[E(X)]2\mathrm{Var}(X) = \mathrm{E}(X^{2}) - [\mathrm{E}(X)]^{2}. For f(x)=427(3x2−x3)f(x) = \dfrac{4}{27}\left(3x^{2} - x^{3}\right):

E(X)=427∫03(3x3−x4)dx=427[3x44−x55]03=427(2434−2435)=427⋅24320=95=1.8\begin{aligned}\mathrm{E}(X) &= \frac{4}{27}\int_{0}^{3} \left(3x^{3} - x^{4}\right)dx \\[6pt] &= \frac{4}{27}\left[\frac{3x^{4}}{4} - \frac{x^{5}}{5}\right]_{0}^{3} \\[6pt] &= \frac{4}{27}\left(\frac{243}{4} - \frac{243}{5}\right) = \frac{4}{27}\cdot\frac{243}{20} = \frac{9}{5} = 1.8\end{aligned}E(X2)=427∫03(3x4−x5)dx=427[3x55−x66]03=427(7295−7296)=427⋅72930=185=3.6\begin{aligned}\mathrm{E}(X^{2}) &= \frac{4}{27}\int_{0}^{3} \left(3x^{4} - x^{5}\right)dx \\[6pt] &= \frac{4}{27}\left[\frac{3x^{5}}{5} - \frac{x^{6}}{6}\right]_{0}^{3} \\[6pt] &= \frac{4}{27}\left(\frac{729}{5} - \frac{729}{6}\right) = \frac{4}{27}\cdot\frac{729}{30} = \frac{18}{5} = 3.6\end{aligned}Var(X)=185−(95)2=9025−8125=925=0.36\mathrm{Var}(X) = \frac{18}{5} - \left(\frac{9}{5}\right)^{2} = \frac{90}{25} - \frac{81}{25} = \frac{9}{25} = 0.36σ=35=0.6\sigma = \frac{3}{5} = 0.6
  • The xx goes in before you integrate. ∫f(x) dx\int f(x)\,dx alone is just 1.
  • Figure 3 shows the mean 1.81.8 below the median 1.841.84, below the mode 22. Its inset stretches the small gap between mean and median.
  • The long tail runs left (negative skew). A tail pulls the mean more than the median, because the mean weights values by how far out they lie. A right tail reverses the order. A symmetric single-peak pdf has all three equal.
    • Use the order to check your numbers.

Example: for f(x)=32a3(a2−x2)f(x) = \dfrac{3}{2a^{3}}\left(a^{2} - x^{2}\right) on [0,a][0, a], treat aa as a constant while integrating:

E(X)=32a3∫0a(a2x−x3)dx=32a3(a42−a44)=3a8\mathrm{E}(X) = \frac{3}{2a^{3}}\int_{0}^{a} \left(a^{2}x - x^{3}\right)dx = \frac{3}{2a^{3}}\left(\frac{a^{4}}{2} - \frac{a^{4}}{4}\right) = \frac{3a}{8}E(X2)=32a3∫0a(a2x2−x4)dx=32a3(a53−a55)=a25\mathrm{E}(X^{2}) = \frac{3}{2a^{3}}\int_{0}^{a} \left(a^{2}x^{2} - x^{4}\right)dx = \frac{3}{2a^{3}}\left(\frac{a^{5}}{3} - \frac{a^{5}}{5}\right) = \frac{a^{2}}{5}Var(X)=a25−9a264=19a2320\mathrm{Var}(X) = \frac{a^{2}}{5} - \frac{9a^{2}}{64} = \frac{19a^{2}}{320}

Given E(X)=3\mathrm{E}(X) = 3, a=8a = 8 and Var(X)=19×64320=3.8\mathrm{Var}(X) = \tfrac{19 \times 64}{320} = 3.8.

The density falls from x=0x = 0, so the mode is the endpoint 0. The median solves 3a2m−m3=a33a^{2}m - m^{3} = a^{3}, which for a=8a = 8 gives m=2.78m = 2.78 on the GDC. Mode < median < mean: a right tail.

Example: for f(x)=2sin⁡xf(x) = 2\sin x on [0,π/3][0, \pi/3], integrate by parts with u=xu = x. This gives E(X)=2[−xcos⁡x+sin⁡x]0π/3=3−π3=0.685\mathrm{E}(X) = 2\left[-x\cos x + \sin x\right]_{0}^{\pi/3} = \sqrt{3} - \dfrac{\pi}{3} = 0.685.

By GDC, E(X2)=0.531\mathrm{E}(X^{2}) = 0.531, so Var(X)=0.0620\mathrm{Var}(X) = 0.0620. The mode 1.051.05, median 0.7230.723 and mean 0.6850.685 show the left-tail order again.

Symmetry shortcut

  • Symmetry shortcut = if the graph of ff is symmetrical about x=cx = c, the mean and median are both cc. So is the mode when there is one peak.
  • Exams ask you to "write down" these from the graph, with no integration. For the arch f(x)=34(1−x2)f(x) = \dfrac{3}{4}(1 - x^{2}) on [−1,1][-1, 1], all three are 0.
  • The variance still needs an integral: Var(X)=2⋅34∫01x2(1−x2) dx=15\mathrm{Var}(X) = 2\cdot\tfrac{3}{4}\int_{0}^{1} x^{2}(1 - x^{2})\,dx = \tfrac{1}{5}. Here μ=0\mu = 0, and doubling the half-integral uses the symmetry.
  • The quartiles of a symmetric pdf sit equally far either side of the centre.

6Piecewise probability density functions

The guide includes piecewise functions: one rule on one interval, another on the next. Every property stands. Each integral is split at the join.

A random variable XX has

f(x)=x6f(x) = \dfrac{x}{6} for 0≤x≤20 \le x \le 2, f(x)=6−x12f(x) = \dfrac{6 - x}{12} for 2<x≤62 < x \le 6, and f(x)=0f(x) = 0 otherwise.

Figure 4 shows a triangle, rising in teal and falling in amber. Both rules give 13\tfrac{1}{3} at x=2x = 2, a useful check on a constant. A pdf may jump at the join.

Figure 4 · A piecewise density: two rules, one area of 1 0 1 2 3 4 5 6 0 0.1 0.2 0.3 x f(x) 1/3 1/6 x/6 (6 − x)/12 median ≈ 2.54 mode 2 f(x) = x/6 on [0, 2] and (6 − x)/12 on (2, 6]. The first piece holds only 1/3 of the area, so the median lies in the second piece, at 6 − 2√3 ≈ 2.54.
Figure 4 · A piecewise density: two rules, one area of 1

Check it is valid. Both pieces are non-negative on their intervals, and

∫02x6 dx=[x212]02=412=13\int_{0}^{2} \frac{x}{6}\,dx = \left[\frac{x^{2}}{12}\right]_{0}^{2} = \frac{4}{12} = \frac{1}{3}∫266−x12 dx=112[6x−x22]26=112(18−10)=23\int_{2}^{6} \frac{6 - x}{12}\,dx = \frac{1}{12}\left[6x - \frac{x^{2}}{2}\right]_{2}^{6} = \frac{1}{12}(18 - 10) = \frac{2}{3}total=13+23=1\text{total} = \frac{1}{3} + \frac{2}{3} = 1

Mode: the highest point is the peak of the triangle, f(2)=13f(2) = \tfrac{1}{3}, so the mode is 2.

Median: the first piece holds only 13\tfrac{1}{3} of the area, less than 12\tfrac{1}{2}. So the median lies in the second piece, and a further 12−13=16\tfrac{1}{2} - \tfrac{1}{3} = \tfrac{1}{6} is needed beyond x=2x = 2. Say which piece holds the median before integrating.

112[6x−x22]2m=16\frac{1}{12}\left[6x - \frac{x^{2}}{2}\right]_{2}^{m} = \frac{1}{6}6m−m22−10=26m - \frac{m^{2}}{2} - 10 = 2m2−12m+24=0m^{2} - 12m + 24 = 0m=6±12=6±23m = 6 \pm \sqrt{12} = 6 \pm 2\sqrt{3}m=6−23≈2.54reject 6+23≈9.46, outside [2,6]m = 6 - 2\sqrt{3} \approx 2.54 \qquad \textcolor{#838c91}{\text{reject }6 + 2\sqrt{3} \approx 9.46\text{, outside }[2, 6]}

With straight-line pieces geometry also works. The triangle right of mm has area (6−m)224=12\dfrac{(6 - m)^{2}}{24} = \dfrac{1}{2}, giving the same mm.

Mean and variance: split each integral at 2.

E(X)=∫02x26 dx+∫26x(6−x)12 dx=49+112[3x2−x33]26=49+112(36−283)=49+209=83\begin{aligned}\mathrm{E}(X) &= \int_{0}^{2} \frac{x^{2}}{6}\,dx + \int_{2}^{6} \frac{x(6 - x)}{12}\,dx \\[6pt] &= \frac{4}{9} + \frac{1}{12}\left[3x^{2} - \frac{x^{3}}{3}\right]_{2}^{6} \\[6pt] &= \frac{4}{9} + \frac{1}{12}\left(36 - \frac{28}{3}\right) = \frac{4}{9} + \frac{20}{9} = \frac{8}{3}\end{aligned}E(X2)=∫02x36 dx+∫26x2(6−x)12 dx=23+8=263\mathrm{E}(X^{2}) = \int_{0}^{2} \frac{x^{3}}{6}\,dx + \int_{2}^{6} \frac{x^{2}(6 - x)}{12}\,dx = \frac{2}{3} + 8 = \frac{26}{3}Var(X)=263−(83)2=789−649=149\mathrm{Var}(X) = \frac{26}{3} - \left(\frac{8}{3}\right)^{2} = \frac{78}{9} - \frac{64}{9} = \frac{14}{9}

Mode 22 < median 2.542.54 < mean 2.672.67. The tail is on the right (positive skew), so the order reverses.

7Linear transformations: E(aX + b) and Var(aX + b)

If every value of XX is multiplied by aa and then has bb added, the new variable is aX+baX + b.

E(aX+b)=aE(X)+b\mathrm{E}(aX + b) = a\mathrm{E}(X) + b and Var(aX+b)=a2Var(X)\mathrm{Var}(aX + b) = a^{2}\mathrm{Var}(X). From the formula booklet.

Why it works:

  • For a discrete XX, E(aX+b)=a∑x P(X=x)+b∑P(X=x)=aE(X)+b\mathrm{E}(aX + b) = a\sum x\,\mathrm{P}(X = x) + b\sum \mathrm{P}(X = x) = a\mathrm{E}(X) + b, since the probabilities add to 1. An integral does the same for a pdf.
  • Each distance from the mean becomes (ax+b)−(aμ+b)=a(x−μ)(ax + b) - (a\mu + b) = a(x - \mu). The bb cancels, and squaring gives a2a^{2}.
  • The standard deviation becomes ∣a∣σ\lvert a\rvert\sigma.

Example: Figure 5 uses the goals from section 2. A fantasy league scores 2 points per goal plus 1 for playing, so points are Y=2X+1Y = 2X + 1.

Figure 5 · Y = 2X + 1 moves the centre and doubles the spread (a) X, goals 0 1 2 3 4 0 0.2 0.4 x P(X = x) mean 1.5 σ = 1.12 (b) Y = 2X + 1, points 1 3 5 7 9 0 0.2 0.4 y P(Y = y) mean 4 σ = 2.24 Adding 1 slides everything along; multiplying by 2 stretches every distance. E(Y) = 2(1.5) + 1 = 4, σ of Y = 2(1.12) = 2.24.
Figure 5 · Y = 2X + 1 moves the centre and doubles the spread
E(Y)=2E(X)+1=2(1.5)+1=4\mathrm{E}(Y) = 2\mathrm{E}(X) + 1 = 2(1.5) + 1 = 4Var(Y)=22 Var(X)=4(1.25)=5the + 1 does not appear\mathrm{Var}(Y) = 2^{2}\,\mathrm{Var}(X) = 4(1.25) = 5 \qquad \textcolor{#838c91}{\text{the }+\,1\text{ does not appear}}σY=5=2.24 (3 s.f.), which is 2×1.12\sigma_{Y} = \sqrt{5} = 2.24 \text{ (3 s.f.), which is } 2 \times 1.12

Example: a fare formula. A taxi charges a fixed $2.50\$2.50 plus $0.80\$0.80 per kilometre. The distance DD has mean 66 km and variance 44 km2^{2}.

The fare C=0.8D+2.5C = 0.8D + 2.5 has E(C)=0.8(6)+2.5=$7.30\mathrm{E}(C) = 0.8(6) + 2.5 = \$7.30 and Var(C)=0.82(4)=2.56\mathrm{Var}(C) = 0.8^{2}(4) = 2.56. So the standard deviation is \$1.60.

The fixed charge moves the mean, not the spread. Likewise the fee in section 2 is the bb in W−cW - c, so it drops out of the variance.

Example: a question may give old and new mean and variance and ask for aa and bb. Let E(X)=4\mathrm{E}(X) = 4, Var(X)=3\mathrm{Var}(X) = 3, and Y=aX+bY = aX + b with E(Y)=1\mathrm{E}(Y) = 1 and Var(Y)=12\mathrm{Var}(Y) = 12.

a2(3)=12, so a=±2a^{2}(3) = 12, \text{ so } a = \pm 2a=2:2(4)+b=1, so b=−7a=−2:−2(4)+b=1, so b=9a = 2: \quad 2(4) + b = 1, \text{ so } b = -7 a = -2: \quad -2(4) + b = 1, \text{ so } b = 9

Variance fixes only ∣a∣\lvert a\rvert. Without a condition such as "a>0a > 0", both pairs are valid.

Cases that catch people: Var(X−5)=Var(−X)=Var(X)\mathrm{Var}(X - 5) = \mathrm{Var}(-X) = \mathrm{Var}(X). Also Var(3−2X)=4Var(X)\mathrm{Var}(3 - 2X) = 4\mathrm{Var}(X), not −2Var(X)-2\mathrm{Var}(X) or 4Var(X)+34\mathrm{Var}(X) + 3.

Practice questions

35 questions on this note, from easy to hard. Each one you get right lights a star of this topic's constellation.